Back to index

php5  5.3.10
php.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Authors: Andi Gutmans <andi@zend.com>                                |
00016    |          Zeev Suraski <zeev@zend.com>                                |
00017    +----------------------------------------------------------------------+
00018  */
00019 
00020 /* $Id: php.h 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifndef PHP_H
00023 #define PHP_H
00024 
00025 #ifdef HAVE_DMALLOC
00026 #include <dmalloc.h>
00027 #endif
00028 
00029 #define PHP_API_VERSION 20090626
00030 #define PHP_HAVE_STREAMS
00031 #define YYDEBUG 0
00032 
00033 #include "php_version.h"
00034 #include "zend.h"
00035 #include "zend_qsort.h"
00036 #include "php_compat.h"
00037 
00038 #include "zend_API.h"
00039 
00040 #undef sprintf
00041 #define sprintf php_sprintf
00042 
00043 /* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
00044 #undef PHP_DEBUG
00045 #define PHP_DEBUG ZEND_DEBUG
00046 
00047 #ifdef PHP_WIN32
00048 #      include "tsrm_win32.h"
00049 #      include "win95nt.h"
00050 #      ifdef PHP_EXPORTS
00051 #             define PHPAPI __declspec(dllexport)
00052 #      else
00053 #             define PHPAPI __declspec(dllimport)
00054 #      endif
00055 #      define PHP_DIR_SEPARATOR '\\'
00056 #      define PHP_EOL "\r\n"
00057 #else
00058 #      if defined(__GNUC__) && __GNUC__ >= 4
00059 #             define PHPAPI __attribute__ ((visibility("default")))
00060 #      else
00061 #             define PHPAPI
00062 #      endif
00063 
00064 #define THREAD_LS
00065 #define PHP_DIR_SEPARATOR '/'
00066 #if defined(__MacOSX__)
00067 #define PHP_EOL "\r"
00068 #else 
00069 #define PHP_EOL "\n"
00070 #endif
00071 #endif
00072 
00073 #ifdef NETWARE
00074 /* For php_get_uname() function */
00075 #define PHP_UNAME  "NetWare"
00076 #define PHP_OS      PHP_UNAME
00077 #endif
00078 
00079 #if HAVE_ASSERT_H
00080 #if PHP_DEBUG
00081 #undef NDEBUG
00082 #else
00083 #ifndef NDEBUG
00084 #define NDEBUG
00085 #endif
00086 #endif
00087 #include <assert.h>
00088 #else /* HAVE_ASSERT_H */
00089 #define assert(expr) ((void) (0))
00090 #endif /* HAVE_ASSERT_H */
00091 
00092 #define APACHE 0
00093 
00094 #if HAVE_UNIX_H
00095 #include <unix.h>
00096 #endif
00097 
00098 #if HAVE_ALLOCA_H
00099 #include <alloca.h>
00100 #endif
00101 
00102 #if HAVE_BUILD_DEFS_H
00103 #include <build-defs.h>
00104 #endif
00105 
00106 /*
00107  * This is a fast version of strlcpy which should be used, if you
00108  * know the size of the destination buffer and if you know
00109  * the length of the source string.
00110  *
00111  * size is the allocated number of bytes of dst
00112  * src_size is the number of bytes excluding the NUL of src
00113  */
00114 
00115 #define PHP_STRLCPY(dst, src, size, src_size)    \
00116        {                                                                            \
00117               size_t php_str_len;                                     \
00118                                                                                     \
00119               if (src_size >= size)                                   \
00120                      php_str_len = size - 1;                          \
00121               else                                                           \
00122                      php_str_len = src_size;                          \
00123               memcpy(dst, src, php_str_len);                   \
00124               dst[php_str_len] = '\0';                         \
00125        }
00126 
00127 #ifndef HAVE_STRLCPY
00128 BEGIN_EXTERN_C()
00129 PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz);
00130 END_EXTERN_C()
00131 #undef strlcpy
00132 #define strlcpy php_strlcpy
00133 #endif
00134 
00135 #ifndef HAVE_STRLCAT
00136 BEGIN_EXTERN_C()
00137 PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz);
00138 END_EXTERN_C()
00139 #undef strlcat
00140 #define strlcat php_strlcat
00141 #endif
00142 
00143 #ifndef HAVE_STRTOK_R
00144 BEGIN_EXTERN_C()
00145 char *strtok_r(char *s, const char *delim, char **last);
00146 END_EXTERN_C()
00147 #endif
00148 
00149 #ifndef HAVE_SOCKLEN_T
00150 typedef unsigned int socklen_t;
00151 #endif
00152 
00153 #define CREATE_MUTEX(a, b)
00154 #define SET_MUTEX(a)
00155 #define FREE_MUTEX(a)
00156 
00157 /*
00158  * Then the ODBC support can use both iodbc and Solid,
00159  * uncomment this.
00160  * #define HAVE_ODBC (HAVE_IODBC|HAVE_SOLID)
00161  */
00162 
00163 #include <stdlib.h>
00164 #include <ctype.h>
00165 #if HAVE_UNISTD_H
00166 #include <unistd.h>
00167 #endif
00168 #if HAVE_STDARG_H
00169 #include <stdarg.h>
00170 #else
00171 # if HAVE_SYS_VARARGS_H
00172 # include <sys/varargs.h>
00173 # endif
00174 #endif
00175 
00176 #ifndef va_copy
00177 # ifdef __va_copy
00178 #  define va_copy(ap1, ap2)         __va_copy((ap1), (ap2))
00179 # else
00180 #  define va_copy(ap1, ap2)         memcpy((&ap1), (&ap2), sizeof(va_list))
00181 # endif
00182 #endif
00183 
00184 #include "zend_hash.h"
00185 #include "php3_compat.h"
00186 #include "zend_alloc.h"
00187 #include "zend_stack.h"
00188 
00189 #if STDC_HEADERS
00190 # include <string.h>
00191 #else
00192 # ifndef HAVE_MEMCPY
00193 #  define memcpy(d, s, n)   bcopy((s), (d), (n))
00194 # endif
00195 # ifndef HAVE_MEMMOVE
00196 #  define memmove(d, s, n)  bcopy ((s), (d), (n))
00197 # endif
00198 #endif
00199 
00200 #include "safe_mode.h"
00201 
00202 #ifndef HAVE_STRERROR
00203 char *strerror(int);
00204 #endif
00205 
00206 #if HAVE_PWD_H
00207 # ifdef PHP_WIN32
00208 #include "win32/param.h"
00209 # else
00210 #include <pwd.h>
00211 #include <sys/param.h>
00212 # endif
00213 #endif
00214 
00215 #if HAVE_LIMITS_H
00216 #include <limits.h>
00217 #endif
00218 
00219 #ifndef LONG_MAX
00220 #define LONG_MAX 2147483647L
00221 #endif
00222 
00223 #ifndef LONG_MIN
00224 #define LONG_MIN (- LONG_MAX - 1)
00225 #endif
00226 
00227 #ifndef INT_MAX
00228 #define INT_MAX 2147483647
00229 #endif
00230 
00231 #ifndef INT_MIN
00232 #define INT_MIN (- INT_MAX - 1)
00233 #endif
00234 
00235 #define PHP_GCC_VERSION ZEND_GCC_VERSION
00236 #define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC
00237 #define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT
00238 
00239 BEGIN_EXTERN_C()
00240 #include "snprintf.h"
00241 END_EXTERN_C()
00242 #include "spprintf.h"
00243 
00244 #define EXEC_INPUT_BUF 4096
00245 
00246 #define PHP_MIME_TYPE "application/x-httpd-php"
00247 
00248 /* macros */
00249 #define STR_PRINT(str)      ((str)?(str):"")
00250 
00251 #ifndef MAXPATHLEN
00252 # ifdef PATH_MAX
00253 #  define MAXPATHLEN PATH_MAX
00254 # elif defined(MAX_PATH)
00255 #  define MAXPATHLEN MAX_PATH
00256 # else
00257 #  define MAXPATHLEN 256    /* Should be safe for any weird systems that do not define it */
00258 # endif
00259 #endif
00260 
00261 
00262 /* global variables */
00263 #if !defined(PHP_WIN32)
00264 #define PHP_SLEEP_NON_VOID
00265 #define php_sleep sleep
00266 extern char **environ;
00267 #endif /* !defined(PHP_WIN32) */
00268 
00269 #ifdef PHP_PWRITE_64
00270 ssize_t pwrite(int, void *, size_t, off64_t);
00271 #endif
00272 
00273 #ifdef PHP_PREAD_64
00274 ssize_t pread(int, void *, size_t, off64_t);
00275 #endif
00276 
00277 BEGIN_EXTERN_C()
00278 void phperror(char *error);
00279 PHPAPI int php_write(void *buf, uint size TSRMLS_DC);
00280 PHPAPI int php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
00281               2);
00282 PHPAPI void php_log_err(char *log_message TSRMLS_DC);
00283 int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
00284 int cfgparse(void);
00285 END_EXTERN_C()
00286 
00287 #define php_error zend_error
00288 #define error_handling_t zend_error_handling_t
00289 
00290 BEGIN_EXTERN_C()
00291 static inline ZEND_ATTRIBUTE_DEPRECATED void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC)
00292 {
00293        zend_replace_error_handling(error_handling, exception_class, NULL TSRMLS_CC);
00294 }
00295 static inline ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling() {}
00296 
00297 PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC) PHP_ATTRIBUTE_FORMAT(printf, 4, 0);
00298 
00299 #ifdef ZTS
00300 #define PHP_ATTR_FMT_OFFSET 1
00301 #else
00302 #define PHP_ATTR_FMT_OFFSET 0
00303 #endif
00304 
00305 /* PHPAPI void php_error(int type, const char *format, ...); */
00306 PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...)
00307        PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 3, PHP_ATTR_FMT_OFFSET + 4);
00308 PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, const char *format, ...)
00309        PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 4, PHP_ATTR_FMT_OFFSET + 5);
00310 PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...)
00311        PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 5, PHP_ATTR_FMT_OFFSET + 6);
00312 #ifdef PHP_WIN32
00313 PHPAPI void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2 TSRMLS_DC);
00314 #endif
00315 END_EXTERN_C()
00316 
00317 #define php_error_docref php_error_docref0
00318 
00319 #define zenderror phperror
00320 #define zendlex phplex
00321 
00322 #define phpparse zendparse
00323 #define phprestart zendrestart
00324 #define phpin zendin
00325 
00326 #define php_memnstr zend_memnstr
00327 
00328 /* functions */
00329 BEGIN_EXTERN_C()
00330 PHPAPI extern int (*php_register_internal_extensions_func)(TSRMLS_D);
00331 PHPAPI int php_register_internal_extensions(TSRMLS_D);
00332 PHPAPI int php_mergesort(void *base, size_t nmemb, register size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC);
00333 PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
00334 PHPAPI void php_com_initialize(TSRMLS_D);
00335 END_EXTERN_C()
00336 
00337 /* PHP-named Zend macro wrappers */
00338 #define PHP_FN                                   ZEND_FN
00339 #define PHP_MN                                   ZEND_MN
00340 #define PHP_NAMED_FUNCTION         ZEND_NAMED_FUNCTION
00341 #define PHP_FUNCTION               ZEND_FUNCTION
00342 #define PHP_METHOD                 ZEND_METHOD
00343 
00344 #define PHP_RAW_NAMED_FE ZEND_RAW_NAMED_FE
00345 #define PHP_NAMED_FE ZEND_NAMED_FE
00346 #define PHP_FE                     ZEND_FE
00347 #define PHP_DEP_FE      ZEND_DEP_FE
00348 #define PHP_FALIAS          ZEND_FALIAS
00349 #define PHP_DEP_FALIAS      ZEND_DEP_FALIAS
00350 #define PHP_ME          ZEND_ME
00351 #define PHP_MALIAS      ZEND_MALIAS
00352 #define PHP_ABSTRACT_ME ZEND_ABSTRACT_ME
00353 #define PHP_ME_MAPPING  ZEND_ME_MAPPING
00354 #define PHP_FE_END      ZEND_FE_END
00355 
00356 #define PHP_MODULE_STARTUP_N       ZEND_MODULE_STARTUP_N
00357 #define PHP_MODULE_SHUTDOWN_N      ZEND_MODULE_SHUTDOWN_N
00358 #define PHP_MODULE_ACTIVATE_N      ZEND_MODULE_ACTIVATE_N
00359 #define PHP_MODULE_DEACTIVATE_N    ZEND_MODULE_DEACTIVATE_N
00360 #define PHP_MODULE_INFO_N          ZEND_MODULE_INFO_N
00361 
00362 #define PHP_MODULE_STARTUP_D       ZEND_MODULE_STARTUP_D
00363 #define PHP_MODULE_SHUTDOWN_D      ZEND_MODULE_SHUTDOWN_D
00364 #define PHP_MODULE_ACTIVATE_D      ZEND_MODULE_ACTIVATE_D
00365 #define PHP_MODULE_DEACTIVATE_D    ZEND_MODULE_DEACTIVATE_D
00366 #define PHP_MODULE_INFO_D          ZEND_MODULE_INFO_D
00367 
00368 /* Compatibility macros */
00369 #define PHP_MINIT           ZEND_MODULE_STARTUP_N
00370 #define PHP_MSHUTDOWN       ZEND_MODULE_SHUTDOWN_N
00371 #define PHP_RINIT           ZEND_MODULE_ACTIVATE_N
00372 #define PHP_RSHUTDOWN       ZEND_MODULE_DEACTIVATE_N
00373 #define PHP_MINFO           ZEND_MODULE_INFO_N
00374 #define PHP_GINIT           ZEND_GINIT
00375 #define PHP_GSHUTDOWN       ZEND_GSHUTDOWN
00376 
00377 #define PHP_MINIT_FUNCTION         ZEND_MODULE_STARTUP_D
00378 #define PHP_MSHUTDOWN_FUNCTION     ZEND_MODULE_SHUTDOWN_D
00379 #define PHP_RINIT_FUNCTION         ZEND_MODULE_ACTIVATE_D
00380 #define PHP_RSHUTDOWN_FUNCTION     ZEND_MODULE_DEACTIVATE_D
00381 #define PHP_MINFO_FUNCTION         ZEND_MODULE_INFO_D
00382 #define PHP_GINIT_FUNCTION         ZEND_GINIT_FUNCTION
00383 #define PHP_GSHUTDOWN_FUNCTION     ZEND_GSHUTDOWN_FUNCTION
00384  
00385 #define PHP_MODULE_GLOBALS         ZEND_MODULE_GLOBALS
00386 
00387 
00388 /* Output support */
00389 #include "main/php_output.h"
00390 #define PHPWRITE(str, str_len)            php_body_write((str), (str_len) TSRMLS_CC)
00391 #define PUTS(str)                                do {                 \
00392        const char *__str = (str);                                     \
00393        php_body_write(__str, strlen(__str) TSRMLS_CC);  \
00394 } while (0)
00395 
00396 #define PUTC(c)                                         (php_body_write(&(c), 1 TSRMLS_CC), (c))
00397 #define PHPWRITE_H(str, str_len)   php_header_write((str), (str_len) TSRMLS_CC)
00398 #define PUTS_H(str)                              do {                        \
00399        const char *__str = (str);                                            \
00400        php_header_write(__str, strlen(__str) TSRMLS_CC);       \
00401 } while (0)
00402 
00403 #define PUTC_H(c)                                (php_header_write(&(c), 1 TSRMLS_CC), (c))
00404 
00405 #include "php_streams.h"
00406 #include "php_memory_streams.h"
00407 #include "fopen_wrappers.h"
00408 
00409 
00410 /* Virtual current working directory support */
00411 #include "tsrm_virtual_cwd.h"
00412 
00413 #include "zend_constants.h"
00414 
00415 /* connection status states */
00416 #define PHP_CONNECTION_NORMAL  0
00417 #define PHP_CONNECTION_ABORTED 1
00418 #define PHP_CONNECTION_TIMEOUT 2
00419 
00420 #include "php_reentrancy.h"
00421 
00422 /* Finding offsets of elements within structures.
00423  * Taken from the Apache code, which in turn, was taken from X code...
00424  */
00425 
00426 #ifndef XtOffset
00427 #if defined(CRAY) || (defined(__arm) && !(defined(LINUX) || defined(__riscos__)))
00428 #ifdef __STDC__
00429 #define XtOffset(p_type, field) _Offsetof(p_type, field)
00430 #else
00431 #ifdef CRAY2
00432 #define XtOffset(p_type, field) \
00433     (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
00434 
00435 #else /* !CRAY2 */
00436 
00437 #define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
00438 
00439 #endif /* !CRAY2 */
00440 #endif /* __STDC__ */
00441 #else /* ! (CRAY || __arm) */
00442 
00443 #define XtOffset(p_type, field) \
00444     ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
00445 
00446 #endif /* !CRAY */
00447 #endif /* ! XtOffset */
00448 
00449 #ifndef XtOffsetOf
00450 #ifdef offsetof
00451 #define XtOffsetOf(s_type, field) offsetof(s_type, field)
00452 #else
00453 #define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
00454 #endif
00455 #endif /* !XtOffsetOf */
00456 
00457 #endif
00458 
00459 /*
00460  * Local variables:
00461  * tab-width: 4
00462  * c-basic-offset: 4
00463  * End:
00464  * vim600: sw=4 ts=4 fdm=marker
00465  * vim<600: sw=4 ts=4
00466  */