2008-06-24 19:19:20 +00:00
|
|
|
#ifndef _LIGHTTPD_SETTINGS_H_
|
|
|
|
#define _LIGHTTPD_SETTINGS_H_
|
|
|
|
|
2021-08-05 10:29:46 +00:00
|
|
|
#include <lighttpd/hedley.h>
|
|
|
|
|
2008-11-18 20:12:10 +00:00
|
|
|
/* check which OS we are compiling for */
|
|
|
|
#if defined(__BEOS__)
|
|
|
|
# define LIGHTY_OS_BEOS
|
|
|
|
#elif (defined(__APPLE__) && defined(__GNUC__)) || defined(__MACOSX__)
|
|
|
|
# define LIGHTY_OS_MACOSX
|
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
# define LIGHTY_OS_FREEBSD
|
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
# define LIGHTY_OS_NETBSD
|
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
# define LIGHTY_OS_OPENBSD
|
|
|
|
#elif defined(__sgi)
|
|
|
|
# define LIGHTY_OS_IRIX
|
|
|
|
#elif defined(__AIX)
|
|
|
|
# define LIGHTY_OS_AIX
|
|
|
|
#elif defined(__LINUX__) || defined(__linux__) || defined(__linux)
|
|
|
|
# define LIGHTY_OS_LINUX
|
2009-05-31 11:57:17 +00:00
|
|
|
#elif defined(__SUN__) || defined(__sun) || defined(sun)
|
2008-11-18 20:12:10 +00:00
|
|
|
# define LIGHTY_OS_SOLARIS
|
|
|
|
#elif defined(__hpux__) || defined(__hpux)
|
|
|
|
# define LIGHTY_OS_HPUX
|
|
|
|
#elif defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
|
|
|
|
# define LIGHTY_OS_WINDOWS
|
|
|
|
# define LIGHTY_OS_WIN64
|
|
|
|
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
|
|
|
# define LIGHTY_OS_WINDOWS
|
|
|
|
# define LIGHTY_OS_WIN32
|
|
|
|
#else
|
|
|
|
# warning "unknown OS, please report this"
|
|
|
|
#endif
|
|
|
|
|
2013-07-20 09:45:09 +00:00
|
|
|
/* FreeBSD doesn't export special stuff if any feature test macro is set */
|
|
|
|
#ifdef LIGHTY_OS_LINUX
|
|
|
|
# define _XOPEN_SOURCE 600
|
|
|
|
# ifndef _GNU_SOURCE
|
|
|
|
# define _GNU_SOURCE 1
|
|
|
|
# endif
|
2016-08-27 09:32:19 +00:00
|
|
|
# ifndef _DEFAULT_SOURCE
|
|
|
|
# define _DEFAULT_SOURCE 1
|
2013-07-20 09:45:09 +00:00
|
|
|
# endif
|
2013-06-08 22:52:01 +00:00
|
|
|
#endif
|
2008-11-18 20:12:10 +00:00
|
|
|
|
2008-06-24 19:19:20 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2009-07-31 18:36:37 +00:00
|
|
|
# include <lighttpd/config.h>
|
2008-06-24 19:19:20 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-24 11:16:51 +00:00
|
|
|
#define GLIB_DISABLE_DEPRECATION_WARNINGS
|
|
|
|
|
2008-07-17 15:36:46 +00:00
|
|
|
#include <ev.h>
|
2008-06-24 19:19:20 +00:00
|
|
|
#include <glib.h>
|
2008-07-08 19:29:02 +00:00
|
|
|
#include <gmodule.h>
|
2008-06-24 19:19:20 +00:00
|
|
|
|
2013-05-22 16:42:21 +00:00
|
|
|
#define LI_GOFFSET_FORMAT G_GINT64_FORMAT
|
|
|
|
#define LI_GOFFSET_MODIFIER G_GINT64_MODIFIER
|
2008-07-25 22:42:08 +00:00
|
|
|
|
2009-10-10 17:27:42 +00:00
|
|
|
#define CONST_STR_LEN(x) (x), (sizeof(x) - 1)
|
|
|
|
#define CONST_USTR_LEN(x) ((const guchar*) (x)), (sizeof(x) - 1)
|
2008-10-28 21:11:50 +00:00
|
|
|
|
2010-10-07 16:31:21 +00:00
|
|
|
#define GSTR_SAFE_LEN(x) ((x) ? (x)->str : ""), ((x) ? (x)->len : 0)
|
|
|
|
#define GUSTR_SAFE_LEN(x) (const guchar*) ((x) ? (x)->str : ""), (x) ? (x)->len : 0
|
|
|
|
#define GSTR_LEN(x) ((x)->str), ((x)->len)
|
|
|
|
#define GUSTR_LEN(x) ((const guchar*) ((x)->str)), ((x)->len)
|
2008-10-28 21:11:50 +00:00
|
|
|
#define GSTR_SAFE_STR(x) ((x && x->str) ? x->str : "(null)")
|
2008-07-25 22:42:08 +00:00
|
|
|
|
2008-06-24 19:19:20 +00:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_STDINT_H
|
|
|
|
# include <stdint.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_STDDEF_H
|
|
|
|
# include <stddef.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_INTTYPES_H
|
|
|
|
# include <inttypes.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
2009-04-17 20:14:20 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2010-07-31 13:16:29 +00:00
|
|
|
#include <dirent.h>
|
|
|
|
#include <unistd.h>
|
2010-07-31 14:11:32 +00:00
|
|
|
#include <sys/wait.h>
|
2010-07-31 13:16:29 +00:00
|
|
|
|
|
|
|
#if defined(LIGHTY_OS_LINUX)
|
|
|
|
# include <sched.h>
|
|
|
|
#endif
|
2008-06-24 19:19:20 +00:00
|
|
|
|
2008-11-18 20:36:31 +00:00
|
|
|
/* on linux 2.4.x you get either sendfile or LFS */
|
2008-11-23 22:47:10 +00:00
|
|
|
#if defined(LIGHTY_OS_LINUX) && defined(HAVE_SYS_SENDFILE_H) && defined(HAVE_SENDFILE) && (defined(_LARGEFILE_SOURCE) || defined(HAVE_SENDFILE64)) && defined(HAVE_WRITEV) && !defined(HAVE_SENDFILE_BROKEN)
|
2008-11-18 20:36:31 +00:00
|
|
|
# define USE_LINUX_SENDFILE
|
|
|
|
# include <sys/sendfile.h>
|
|
|
|
# include <sys/uio.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (defined(LIGHTY_OS_FREEBSD) || defined(__DragonFly__)) && defined(HAVE_SYS_UIO_H) && defined(HAVE_SENDFILE) && defined(HAVE_WRITEV)
|
2008-06-24 19:19:20 +00:00
|
|
|
# define USE_FREEBSD_SENDFILE
|
|
|
|
# include <sys/uio.h>
|
|
|
|
#endif
|
|
|
|
|
2008-11-18 20:36:31 +00:00
|
|
|
#if defined(LIGHT_OS_SOLARIS) && defined(HAVE_SYS_SENDFILE_H) && defined(HAVE_SENDFILEV) && defined(HAVE_WRITEV)
|
2008-06-24 19:19:20 +00:00
|
|
|
# define USE_SOLARIS_SENDFILEV
|
|
|
|
# include <sys/sendfile.h>
|
|
|
|
# include <sys/uio.h>
|
|
|
|
#endif
|
|
|
|
|
2008-11-18 20:36:31 +00:00
|
|
|
#if defined(LIGHTY_OS_MACOSX) && defined(HAVE_SYS_UIO_H) && defined(HAVE_SENDFILE)
|
2008-11-17 19:24:36 +00:00
|
|
|
# define USE_OSX_SENDFILE
|
|
|
|
# include <sys/uio.h>
|
|
|
|
#endif
|
|
|
|
|
2008-11-18 20:36:31 +00:00
|
|
|
#if defined(HAVE_SYS_UIO_H) && defined(HAVE_WRITEV)
|
2008-06-24 19:19:20 +00:00
|
|
|
# define USE_WRITEV
|
|
|
|
# include <sys/uio.h>
|
|
|
|
#endif
|
|
|
|
|
2008-11-18 20:36:31 +00:00
|
|
|
#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MMAP)
|
2008-06-24 19:19:20 +00:00
|
|
|
# define USE_MMAP
|
|
|
|
# include <sys/mman.h>
|
|
|
|
/* NetBSD 1.3.x needs it */
|
|
|
|
# ifndef MAP_FAILED
|
|
|
|
# define MAP_FAILED -1
|
|
|
|
# endif
|
|
|
|
|
|
|
|
#if defined(MAP_ANON)
|
2008-11-18 20:36:31 +00:00
|
|
|
# define HAVE_MEM_MMAP_ANON
|
2008-06-24 19:19:20 +00:00
|
|
|
#else
|
|
|
|
/* let's try /dev/zero */
|
2008-11-18 20:36:31 +00:00
|
|
|
# define HAVE_MEM_MMAP_ZERO
|
2008-06-24 19:19:20 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-11-18 20:36:31 +00:00
|
|
|
#if defined(LIGHTY_OS_AIX) && defined(HAVE_SYS_UIO_H) && defined(HAVE_WRITEV) && defined(HAVE_SEND_FILE)
|
2008-06-24 19:19:20 +00:00
|
|
|
# define USE_AIX_SENDFILE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* unix can use read/write or recv/send on sockets
|
|
|
|
* win32 only recv/send
|
|
|
|
*/
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
# define WIN32_LEAN_AND_MEAN
|
|
|
|
# define NOGDI
|
|
|
|
# define USE_WIN32_SEND
|
|
|
|
/* wait for async-io support
|
|
|
|
# define USE_WIN32_TRANSMITFILE
|
|
|
|
*/
|
|
|
|
#else
|
|
|
|
# define USE_WRITE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef LI_DECLARE_EXPORTS
|
2021-08-05 10:29:46 +00:00
|
|
|
# define LI_API HEDLEY_PUBLIC
|
2008-06-24 19:19:20 +00:00
|
|
|
#else
|
2021-08-05 10:29:46 +00:00
|
|
|
# define LI_API HEDLEY_IMPORT
|
2008-06-24 19:19:20 +00:00
|
|
|
#endif
|
|
|
|
|
2008-06-29 15:48:28 +00:00
|
|
|
#define UNUSED(x) ( (void)(x) )
|
|
|
|
|
2021-08-05 10:29:46 +00:00
|
|
|
#define INLINE static HEDLEY_INLINE
|
2008-06-24 19:19:20 +00:00
|
|
|
|
2014-02-04 13:20:35 +00:00
|
|
|
#ifdef PACKAGE_NO_BUILD_DATE
|
|
|
|
# undef PACKAGE_BUILD_DATE
|
|
|
|
# define PACKAGE_BUILD_DATE "(build date not available)"
|
|
|
|
#else
|
|
|
|
# ifndef PACKAGE_BUILD_DATE
|
|
|
|
# define PACKAGE_BUILD_DATE __DATE__ " " __TIME__
|
|
|
|
# endif
|
2009-04-15 09:39:21 +00:00
|
|
|
#endif
|
|
|
|
|
2010-07-31 13:16:29 +00:00
|
|
|
#include <lighttpd/sys_memory.h>
|
|
|
|
#include <lighttpd/sys_socket.h>
|
2008-06-24 19:19:20 +00:00
|
|
|
|
2010-08-24 18:17:30 +00:00
|
|
|
#if 0
|
|
|
|
/* on "old" gcc versions (4.1?) poison also hits struct members */
|
2009-07-16 20:10:41 +00:00
|
|
|
#if( 2 < __GNUC__ )
|
|
|
|
#pragma GCC poison strtok asctime ctime tmpnam strerror
|
|
|
|
#ifdef HAVE_LOCALTIME_R
|
|
|
|
#pragma GCC poison localtime
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_GMTIME_R
|
|
|
|
#pragma GCC poison gmtime
|
|
|
|
#endif
|
|
|
|
#endif
|
2010-08-24 18:17:30 +00:00
|
|
|
#endif
|
2009-07-16 20:10:41 +00:00
|
|
|
|
2008-06-24 19:19:20 +00:00
|
|
|
#endif
|