php-src/main/php.h

456 lines
12 KiB
C
Raw Normal View History

2001-04-18 01:03:18 +08:00
/*
1999-04-08 05:05:13 +08:00
+----------------------------------------------------------------------+
2014-09-20 00:33:14 +08:00
| PHP Version 7 |
1999-04-08 05:05:13 +08:00
+----------------------------------------------------------------------+
2015-01-15 23:27:30 +08:00
| Copyright (c) 1997-2015 The PHP Group |
1999-04-08 05:05:13 +08:00
+----------------------------------------------------------------------+
2006-01-01 20:51:34 +08:00
| This source file is subject to version 3.01 of the PHP license, |
1999-07-16 21:13:16 +08:00
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
2006-01-01 20:51:34 +08:00
| http://www.php.net/license/3_01.txt |
1999-07-16 21:13:16 +08:00
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
1999-04-08 05:05:13 +08:00
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@zend.com> |
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef PHP_H
#define PHP_H
1999-04-08 05:05:13 +08:00
1999-06-26 08:34:36 +08:00
#ifdef HAVE_DMALLOC
#include <dmalloc.h>
#endif
#define PHP_API_VERSION 20131218
#define PHP_HAVE_STREAMS
1999-04-08 05:05:13 +08:00
#define YYDEBUG 0
#define PHP_DEFAULT_CHARSET "UTF-8"
1999-04-08 05:05:13 +08:00
#include "php_version.h"
#include "zend.h"
2015-01-14 17:22:58 +08:00
#include "zend_sort.h"
#include "php_compat.h"
1999-04-22 07:28:00 +08:00
1999-04-08 05:05:13 +08:00
#include "zend_API.h"
#undef sprintf
#define sprintf php_sprintf
1999-04-08 05:05:13 +08:00
2002-03-01 08:16:58 +08:00
/* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
#undef PHP_DEBUG
#define PHP_DEBUG ZEND_DEBUG
2000-02-11 23:59:30 +08:00
#ifdef PHP_WIN32
# include "tsrm_win32.h"
# include "win95nt.h"
# ifdef PHP_EXPORTS
# define PHPAPI __declspec(dllexport)
# else
# define PHPAPI __declspec(dllimport)
# endif
# define PHP_DIR_SEPARATOR '\\'
# define PHP_EOL "\r\n"
1999-04-08 05:05:13 +08:00
#else
# if defined(__GNUC__) && __GNUC__ >= 4
# define PHPAPI __attribute__ ((visibility("default")))
# else
# define PHPAPI
# endif
2012-02-27 20:16:39 +08:00
# define THREAD_LS
# define PHP_DIR_SEPARATOR '/'
# define PHP_EOL "\n"
1999-04-08 05:05:13 +08:00
#endif
2002-05-31 12:49:45 +08:00
#ifdef NETWARE
/* For php_get_uname() function */
#define PHP_UNAME "NetWare"
#define PHP_OS PHP_UNAME
2002-05-31 12:49:45 +08:00
#endif
#if HAVE_ASSERT_H
#if PHP_DEBUG
#undef NDEBUG
#else
#ifndef NDEBUG
#define NDEBUG
#endif
#endif
#include <assert.h>
#else /* HAVE_ASSERT_H */
#define assert(expr) ((void) (0))
#endif /* HAVE_ASSERT_H */
1999-04-08 05:05:13 +08:00
#define APACHE 0
1999-04-08 05:05:13 +08:00
#if HAVE_UNIX_H
#include <unix.h>
#endif
#if HAVE_ALLOCA_H
#include <alloca.h>
#endif
#if HAVE_BUILD_DEFS_H
2005-01-15 04:44:28 +08:00
#include <build-defs.h>
#endif
/*
* This is a fast version of strlcpy which should be used, if you
2000-08-27 17:38:33 +08:00
* know the size of the destination buffer and if you know
* the length of the source string.
*
2000-08-27 17:38:33 +08:00
* size is the allocated number of bytes of dst
* src_size is the number of bytes excluding the NUL of src
*/
#define PHP_STRLCPY(dst, src, size, src_size) \
{ \
size_t php_str_len; \
\
if (src_size >= size) \
php_str_len = size - 1; \
else \
php_str_len = src_size; \
memcpy(dst, src, php_str_len); \
dst[php_str_len] = '\0'; \
}
1999-09-15 17:35:20 +08:00
#ifndef HAVE_STRLCPY
2003-09-02 21:07:17 +08:00
BEGIN_EXTERN_C()
2001-05-30 13:00:39 +08:00
PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz);
2003-09-02 21:07:17 +08:00
END_EXTERN_C()
2003-06-27 15:43:42 +08:00
#undef strlcpy
2001-05-30 13:00:39 +08:00
#define strlcpy php_strlcpy
#endif
1999-09-15 17:35:20 +08:00
#ifndef HAVE_STRLCAT
2003-09-02 21:07:17 +08:00
BEGIN_EXTERN_C()
2001-05-30 13:00:39 +08:00
PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz);
2003-09-02 21:07:17 +08:00
END_EXTERN_C()
2003-06-27 15:43:42 +08:00
#undef strlcat
2001-05-30 13:00:39 +08:00
#define strlcat php_strlcat
#endif
1999-11-27 08:48:50 +08:00
#ifndef HAVE_STRTOK_R
2003-09-02 21:07:17 +08:00
BEGIN_EXTERN_C()
1999-11-27 08:48:50 +08:00
char *strtok_r(char *s, const char *delim, char **last);
2003-09-02 21:07:17 +08:00
END_EXTERN_C()
1999-11-27 08:48:50 +08:00
#endif
#ifndef HAVE_SOCKLEN_T
# if PHP_WIN32
typedef int socklen_t;
# else
typedef unsigned int socklen_t;
# endif
#endif
2001-08-05 09:43:02 +08:00
#define CREATE_MUTEX(a, b)
1999-04-08 05:05:13 +08:00
#define SET_MUTEX(a)
#define FREE_MUTEX(a)
/*
* Then the ODBC support can use both iodbc and Solid,
* uncomment this.
* #define HAVE_ODBC (HAVE_IODBC|HAVE_SOLID)
*/
#include <stdlib.h>
#include <ctype.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_STDARG_H
#include <stdarg.h>
2001-04-18 01:03:18 +08:00
#else
1999-04-08 05:05:13 +08:00
# if HAVE_SYS_VARARGS_H
# include <sys/varargs.h>
2001-04-18 01:03:18 +08:00
# endif
#endif
1999-04-08 05:05:13 +08:00
#ifndef va_copy
# ifdef __va_copy
# define va_copy(ap1, ap2) __va_copy((ap1), (ap2))
# else
# define va_copy(ap1, ap2) memcpy((&ap1), (&ap2), sizeof(va_list))
# endif
#endif
1999-04-08 05:05:13 +08:00
#include "php_stdint.h"
1999-04-08 05:05:13 +08:00
#include "zend_hash.h"
#include "zend_alloc.h"
#include "zend_stack.h"
#if STDC_HEADERS
# include <string.h>
#else
# ifndef HAVE_MEMCPY
# define memcpy(d, s, n) bcopy((s), (d), (n))
# endif
# ifndef HAVE_MEMMOVE
1999-04-08 05:05:13 +08:00
# define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
#ifndef HAVE_STRERROR
2000-08-21 17:50:53 +08:00
char *strerror(int);
1999-04-08 05:05:13 +08:00
#endif
#if HAVE_PWD_H
2000-02-11 23:59:30 +08:00
# ifdef PHP_WIN32
1999-04-08 05:05:13 +08:00
#include "win32/param.h"
# else
#include <pwd.h>
#include <sys/param.h>
# endif
#endif
#if HAVE_LIMITS_H
#include <limits.h>
#endif
#ifndef LONG_MAX
#define LONG_MAX 2147483647L
#endif
#ifndef LONG_MIN
#define LONG_MIN (- LONG_MAX - 1)
#endif
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN (- INT_MAX - 1)
#endif
#define PHP_GCC_VERSION ZEND_GCC_VERSION
#define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC
2003-08-29 00:49:43 +08:00
#define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT
2003-08-28 13:23:08 +08:00
2004-11-16 05:04:09 +08:00
BEGIN_EXTERN_C()
#include "snprintf.h"
2004-11-16 05:04:09 +08:00
END_EXTERN_C()
2002-04-10 09:13:18 +08:00
#include "spprintf.h"
1999-04-08 05:05:13 +08:00
#define EXEC_INPUT_BUF 4096
1999-12-22 03:40:27 +08:00
#define PHP_MIME_TYPE "application/x-httpd-php"
1999-04-08 05:05:13 +08:00
/* macros */
1999-07-09 03:18:42 +08:00
#define STR_PRINT(str) ((str)?(str):"")
1999-04-08 05:05:13 +08:00
#ifndef MAXPATHLEN
2000-09-07 23:20:29 +08:00
# ifdef PATH_MAX
# define MAXPATHLEN PATH_MAX
# elif defined(MAX_PATH)
# define MAXPATHLEN MAX_PATH
2000-09-07 23:20:29 +08:00
# else
# define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
# endif
1999-04-08 05:05:13 +08:00
#endif
#define php_ignore_value(x) ZEND_IGNORE_VALUE(x)
1999-04-08 05:05:13 +08:00
/* global variables */
2000-02-11 23:59:30 +08:00
#if !defined(PHP_WIN32)
#define PHP_SLEEP_NON_VOID
2002-09-09 19:31:03 +08:00
#define php_sleep sleep
1999-04-08 05:05:13 +08:00
extern char **environ;
#endif /* !defined(PHP_WIN32) */
#ifdef PHP_PWRITE_64
ssize_t pwrite(int, void *, size_t, off64_t);
#endif
#ifdef PHP_PREAD_64
ssize_t pread(int, void *, size_t, off64_t);
#endif
2003-09-02 21:07:17 +08:00
BEGIN_EXTERN_C()
2000-08-21 17:50:53 +08:00
void phperror(char *error);
2014-12-14 06:06:14 +08:00
PHPAPI size_t php_write(void *buf, size_t size);
PHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
2);
PHPAPI int php_get_module_initialized(void);
2015-08-24 23:07:59 +08:00
PHPAPI ZEND_COLD void php_log_err(char *log_message);
int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
int cfgparse(void);
2003-09-02 21:07:17 +08:00
END_EXTERN_C()
1999-04-08 05:05:13 +08:00
#define php_error zend_error
#define error_handling_t zend_error_handling_t
2003-09-02 21:07:17 +08:00
BEGIN_EXTERN_C()
2014-12-14 06:06:14 +08:00
static inline ZEND_ATTRIBUTE_DEPRECATED void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class)
{
2014-12-14 06:06:14 +08:00
zend_replace_error_handling(error_handling, exception_class, NULL);
}
2008-08-08 22:15:05 +08:00
static inline ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling() {}
2015-08-24 23:07:59 +08:00
PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int type, const char *format, va_list args) PHP_ATTRIBUTE_FORMAT(printf, 4, 0);
2003-08-29 00:49:43 +08:00
2014-09-26 00:48:27 +08:00
#ifdef ZTS
2003-08-29 00:49:43 +08:00
#define PHP_ATTR_FMT_OFFSET 1
#else
#define PHP_ATTR_FMT_OFFSET 0
#endif
/* PHPAPI void php_error(int type, const char *format, ...); */
2015-08-24 23:07:59 +08:00
PHPAPI ZEND_COLD void php_error_docref0(const char *docref, int type, const char *format, ...)
PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 3, PHP_ATTR_FMT_OFFSET + 4);
2015-08-24 23:07:59 +08:00
PHPAPI ZEND_COLD void php_error_docref1(const char *docref, const char *param1, int type, const char *format, ...)
PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 4, PHP_ATTR_FMT_OFFSET + 5);
2015-08-24 23:07:59 +08:00
PHPAPI ZEND_COLD void php_error_docref2(const char *docref, const char *param1, const char *param2, int type, const char *format, ...)
PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 5, PHP_ATTR_FMT_OFFSET + 6);
2010-01-27 15:48:31 +08:00
#ifdef PHP_WIN32
2015-08-24 23:07:59 +08:00
PHPAPI ZEND_COLD void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2);
2010-01-27 15:48:31 +08:00
#endif
2003-09-02 21:07:17 +08:00
END_EXTERN_C()
#define php_error_docref php_error_docref0
1999-04-08 05:05:13 +08:00
#define zenderror phperror
#define zendlex phplex
#define phpparse zendparse
#define phprestart zendrestart
#define phpin zendin
#define php_memnstr zend_memnstr
1999-04-08 05:05:13 +08:00
/* functions */
2003-09-02 21:07:17 +08:00
BEGIN_EXTERN_C()
2014-12-14 06:06:14 +08:00
PHPAPI extern int (*php_register_internal_extensions_func)(void);
PHPAPI int php_register_internal_extensions(void);
PHPAPI int php_mergesort(void *base, size_t nmemb, register size_t size, int (*cmp)(const void *, const void *));
PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
2014-12-14 06:06:14 +08:00
PHPAPI void php_com_initialize(void);
PHPAPI char *php_get_current_user(void);
2003-09-02 21:07:17 +08:00
END_EXTERN_C()
1999-04-08 05:05:13 +08:00
/* PHP-named Zend macro wrappers */
#define PHP_FN ZEND_FN
2006-05-26 02:47:21 +08:00
#define PHP_MN ZEND_MN
#define PHP_NAMED_FUNCTION ZEND_NAMED_FUNCTION
#define PHP_FUNCTION ZEND_FUNCTION
#define PHP_METHOD ZEND_METHOD
#define PHP_RAW_NAMED_FE ZEND_RAW_NAMED_FE
#define PHP_NAMED_FE ZEND_NAMED_FE
#define PHP_FE ZEND_FE
2006-02-26 02:25:45 +08:00
#define PHP_DEP_FE ZEND_DEP_FE
#define PHP_FALIAS ZEND_FALIAS
2006-02-26 02:25:45 +08:00
#define PHP_DEP_FALIAS ZEND_DEP_FALIAS
#define PHP_ME ZEND_ME
2004-09-30 16:03:38 +08:00
#define PHP_MALIAS ZEND_MALIAS
2005-08-07 23:13:50 +08:00
#define PHP_ABSTRACT_ME ZEND_ABSTRACT_ME
#define PHP_ME_MAPPING ZEND_ME_MAPPING
#define PHP_FE_END ZEND_FE_END
#define PHP_MODULE_STARTUP_N ZEND_MODULE_STARTUP_N
#define PHP_MODULE_SHUTDOWN_N ZEND_MODULE_SHUTDOWN_N
#define PHP_MODULE_ACTIVATE_N ZEND_MODULE_ACTIVATE_N
#define PHP_MODULE_DEACTIVATE_N ZEND_MODULE_DEACTIVATE_N
#define PHP_MODULE_INFO_N ZEND_MODULE_INFO_N
#define PHP_MODULE_STARTUP_D ZEND_MODULE_STARTUP_D
#define PHP_MODULE_SHUTDOWN_D ZEND_MODULE_SHUTDOWN_D
#define PHP_MODULE_ACTIVATE_D ZEND_MODULE_ACTIVATE_D
#define PHP_MODULE_DEACTIVATE_D ZEND_MODULE_DEACTIVATE_D
#define PHP_MODULE_INFO_D ZEND_MODULE_INFO_D
/* Compatibility macros */
#define PHP_MINIT ZEND_MODULE_STARTUP_N
#define PHP_MSHUTDOWN ZEND_MODULE_SHUTDOWN_N
#define PHP_RINIT ZEND_MODULE_ACTIVATE_N
#define PHP_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
#define PHP_MINFO ZEND_MODULE_INFO_N
#define PHP_GINIT ZEND_GINIT
#define PHP_GSHUTDOWN ZEND_GSHUTDOWN
#define PHP_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
#define PHP_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
#define PHP_RINIT_FUNCTION ZEND_MODULE_ACTIVATE_D
#define PHP_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D
#define PHP_MINFO_FUNCTION ZEND_MODULE_INFO_D
#define PHP_GINIT_FUNCTION ZEND_GINIT_FUNCTION
#define PHP_GSHUTDOWN_FUNCTION ZEND_GSHUTDOWN_FUNCTION
2015-01-03 17:22:58 +08:00
#define PHP_MODULE_GLOBALS ZEND_MODULE_GLOBALS
1999-04-08 05:05:13 +08:00
/* Output support */
2001-07-20 22:40:30 +08:00
#include "main/php_output.h"
1999-04-08 05:05:13 +08:00
#include "php_streams.h"
#include "php_memory_streams.h"
#include "fopen_wrappers.h"
/* Virtual current working directory support */
#include "zend_virtual_cwd.h"
1999-04-08 05:05:13 +08:00
#include "zend_constants.h"
/* connection status states */
#define PHP_CONNECTION_NORMAL 0
#define PHP_CONNECTION_ABORTED 1
#define PHP_CONNECTION_TIMEOUT 2
1999-04-08 05:05:13 +08:00
#include "php_reentrancy.h"
/* Finding offsets of elements within structures.
* Taken from the Apache code, which in turn, was taken from X code...
*/
#ifndef XtOffset
2006-03-08 06:37:53 +08:00
#if defined(CRAY) || (defined(__arm) && !(defined(LINUX) || defined(__riscos__)))
#ifdef __STDC__
2001-08-05 09:43:02 +08:00
#define XtOffset(p_type, field) _Offsetof(p_type, field)
#else
#ifdef CRAY2
2001-08-05 09:43:02 +08:00
#define XtOffset(p_type, field) \
(sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
#else /* !CRAY2 */
2001-08-05 09:43:02 +08:00
#define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
2001-04-18 01:03:18 +08:00
#endif /* !CRAY2 */
#endif /* __STDC__ */
#else /* ! (CRAY || __arm) */
2001-08-05 09:43:02 +08:00
#define XtOffset(p_type, field) \
2014-08-26 17:23:25 +08:00
((zend_long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
#endif /* !CRAY */
#endif /* ! XtOffset */
#ifndef XtOffsetOf
#ifdef offsetof
2001-08-05 09:43:02 +08:00
#define XtOffsetOf(s_type, field) offsetof(s_type, field)
#else
2001-08-05 09:43:02 +08:00
#define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
#endif
#endif /* !XtOffsetOf */
1999-04-08 05:05:13 +08:00
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
1999-04-08 05:05:13 +08:00
*/