You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

436 lines
11 KiB

28 years ago
28 years ago
28 years ago
27 years ago
27 years ago
28 years ago
28 years ago
27 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
22 years ago
22 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
21 years ago
21 years ago
28 years ago
21 years ago
21 years ago
28 years ago
28 years ago
28 years ago
28 years ago
21 years ago
28 years ago
25 years ago
28 years ago
22 years ago
28 years ago
28 years ago
21 years ago
28 years ago
28 years ago
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2008 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Andi Gutmans <andi@zend.com> |
  16. | Zeev Suraski <zeev@zend.com> |
  17. +----------------------------------------------------------------------+
  18. */
  19. /* $Id$ */
  20. #ifndef PHP_H
  21. #define PHP_H
  22. #ifdef HAVE_DMALLOC
  23. #include <dmalloc.h>
  24. #endif
  25. #define PHP_API_VERSION 20070116
  26. #define PHP_HAVE_STREAMS
  27. #define YYDEBUG 0
  28. #include "php_version.h"
  29. #include "zend.h"
  30. #include "zend_qsort.h"
  31. #include "php_compat.h"
  32. #include "zend_API.h"
  33. #undef sprintf
  34. #define sprintf php_sprintf
  35. /* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
  36. #undef PHP_DEBUG
  37. #define PHP_DEBUG ZEND_DEBUG
  38. #ifdef PHP_WIN32
  39. # include "tsrm_win32.h"
  40. # include "win95nt.h"
  41. # ifdef PHP_EXPORTS
  42. # define PHPAPI __declspec(dllexport)
  43. # else
  44. # define PHPAPI __declspec(dllimport)
  45. # endif
  46. # define PHP_DIR_SEPARATOR '\\'
  47. # define PHP_EOL "\r\n"
  48. #else
  49. # if defined(__GNUC__) && __GNUC__ >= 4
  50. # define PHPAPI __attribute__ ((visibility("default")))
  51. # else
  52. # define PHPAPI
  53. # endif
  54. #define THREAD_LS
  55. #define PHP_DIR_SEPARATOR '/'
  56. #if defined(__MacOSX__)
  57. #define PHP_EOL "\r"
  58. #else
  59. #define PHP_EOL "\n"
  60. #endif
  61. #endif
  62. #ifdef NETWARE
  63. /* For php_get_uname() function */
  64. #define PHP_UNAME "NetWare"
  65. #define PHP_OS PHP_UNAME
  66. #endif
  67. #if HAVE_ASSERT_H
  68. #if PHP_DEBUG
  69. #undef NDEBUG
  70. #else
  71. #ifndef NDEBUG
  72. #define NDEBUG
  73. #endif
  74. #endif
  75. #include <assert.h>
  76. #else /* HAVE_ASSERT_H */
  77. #define assert(expr) ((void) (0))
  78. #endif /* HAVE_ASSERT_H */
  79. #define APACHE 0
  80. #if HAVE_UNIX_H
  81. #include <unix.h>
  82. #endif
  83. #if HAVE_ALLOCA_H
  84. #include <alloca.h>
  85. #endif
  86. #if HAVE_BUILD_DEFS_H
  87. #include <build-defs.h>
  88. #endif
  89. /*
  90. * This is a fast version of strlcpy which should be used, if you
  91. * know the size of the destination buffer and if you know
  92. * the length of the source string.
  93. *
  94. * size is the allocated number of bytes of dst
  95. * src_size is the number of bytes excluding the NUL of src
  96. */
  97. #define PHP_STRLCPY(dst, src, size, src_size) \
  98. { \
  99. size_t php_str_len; \
  100. \
  101. if (src_size >= size) \
  102. php_str_len = size - 1; \
  103. else \
  104. php_str_len = src_size; \
  105. memcpy(dst, src, php_str_len); \
  106. dst[php_str_len] = '\0'; \
  107. }
  108. #ifndef HAVE_STRLCPY
  109. BEGIN_EXTERN_C()
  110. PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz);
  111. END_EXTERN_C()
  112. #undef strlcpy
  113. #define strlcpy php_strlcpy
  114. #endif
  115. #ifndef HAVE_STRLCAT
  116. BEGIN_EXTERN_C()
  117. PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz);
  118. END_EXTERN_C()
  119. #undef strlcat
  120. #define strlcat php_strlcat
  121. #endif
  122. #ifndef HAVE_STRTOK_R
  123. BEGIN_EXTERN_C()
  124. char *strtok_r(char *s, const char *delim, char **last);
  125. END_EXTERN_C()
  126. #endif
  127. #ifndef HAVE_SOCKLEN_T
  128. typedef unsigned int socklen_t;
  129. #endif
  130. #define CREATE_MUTEX(a, b)
  131. #define SET_MUTEX(a)
  132. #define FREE_MUTEX(a)
  133. /*
  134. * Then the ODBC support can use both iodbc and Solid,
  135. * uncomment this.
  136. * #define HAVE_ODBC (HAVE_IODBC|HAVE_SOLID)
  137. */
  138. #include <stdlib.h>
  139. #include <ctype.h>
  140. #if HAVE_UNISTD_H
  141. #include <unistd.h>
  142. #endif
  143. #if HAVE_STDARG_H
  144. #include <stdarg.h>
  145. #else
  146. # if HAVE_SYS_VARARGS_H
  147. # include <sys/varargs.h>
  148. # endif
  149. #endif
  150. #include "zend_hash.h"
  151. #include "zend_alloc.h"
  152. #include "zend_stack.h"
  153. /* PHP3 Legacy */
  154. typedef zval pval;
  155. #define function_entry zend_function_entry
  156. #if STDC_HEADERS
  157. # include <string.h>
  158. #else
  159. # ifndef HAVE_MEMCPY
  160. # define memcpy(d, s, n) bcopy((s), (d), (n))
  161. # endif
  162. # ifndef HAVE_MEMMOVE
  163. # define memmove(d, s, n) bcopy ((s), (d), (n))
  164. # endif
  165. #endif
  166. #ifndef HAVE_STRERROR
  167. char *strerror(int);
  168. #endif
  169. #if HAVE_PWD_H
  170. # ifdef PHP_WIN32
  171. #include "win32/param.h"
  172. # else
  173. #include <pwd.h>
  174. #include <sys/param.h>
  175. # endif
  176. #endif
  177. #if HAVE_LIMITS_H
  178. #include <limits.h>
  179. #endif
  180. #ifndef LONG_MAX
  181. #define LONG_MAX 2147483647L
  182. #endif
  183. #ifndef LONG_MIN
  184. #define LONG_MIN (- LONG_MAX - 1)
  185. #endif
  186. #ifndef INT_MAX
  187. #define INT_MAX 2147483647
  188. #endif
  189. #ifndef INT_MIN
  190. #define INT_MIN (- INT_MAX - 1)
  191. #endif
  192. #define PHP_GCC_VERSION ZEND_GCC_VERSION
  193. #define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC
  194. #define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT
  195. BEGIN_EXTERN_C()
  196. #include "snprintf.h"
  197. END_EXTERN_C()
  198. #include "spprintf.h"
  199. #define EXEC_INPUT_BUF 4096
  200. #define PHP_MIME_TYPE "application/x-httpd-php"
  201. /* macros */
  202. #define STR_PRINT(str) ((str)?(str):"")
  203. #ifndef MAXPATHLEN
  204. # ifdef PATH_MAX
  205. # define MAXPATHLEN PATH_MAX
  206. # elif defined(MAX_PATH)
  207. # define MAXPATHLEN MAX_PATH
  208. # else
  209. # define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
  210. # endif
  211. #endif
  212. /* global variables */
  213. #if !defined(PHP_WIN32)
  214. #define PHP_SLEEP_NON_VOID
  215. #define php_sleep sleep
  216. extern char **environ;
  217. #endif /* !defined(PHP_WIN32) */
  218. #ifdef PHP_PWRITE_64
  219. ssize_t pwrite(int, void *, size_t, off64_t);
  220. #endif
  221. #ifdef PHP_PREAD_64
  222. ssize_t pread(int, void *, size_t, off64_t);
  223. #endif
  224. BEGIN_EXTERN_C()
  225. void phperror(char *error);
  226. PHPAPI int php_write(void *buf, uint size TSRMLS_DC);
  227. PHPAPI int php_printf(const char *format, ...);
  228. PHPAPI void php_log_err(char *log_message TSRMLS_DC);
  229. int Debug(char *format, ...);
  230. int cfgparse(void);
  231. END_EXTERN_C()
  232. #define php_error zend_error
  233. #define error_handling_t zend_error_handling_t
  234. BEGIN_EXTERN_C()
  235. PHPAPI void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC);
  236. #define php_std_error_handling() php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC)
  237. PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC);
  238. #ifdef ZTS
  239. #define PHP_ATTR_FMT_OFFSET 1
  240. #else
  241. #define PHP_ATTR_FMT_OFFSET 0
  242. #endif
  243. /* PHPAPI void php_error(int type, const char *format, ...); */
  244. PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...);
  245. PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, const char *format, ...);
  246. PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...);
  247. END_EXTERN_C()
  248. #define php_error_docref php_error_docref0
  249. #define zenderror phperror
  250. #define zendlex phplex
  251. #define phpparse zendparse
  252. #define phprestart zendrestart
  253. #define phpin zendin
  254. #define php_memnstr zend_memnstr
  255. /* functions */
  256. BEGIN_EXTERN_C()
  257. int php_register_internal_extensions(TSRMLS_D);
  258. int php_mergesort(void *base, size_t nmemb, register size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC);
  259. PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
  260. PHPAPI void php_com_initialize(TSRMLS_D);
  261. END_EXTERN_C()
  262. /* PHP-named Zend macro wrappers */
  263. #define PHP_FN ZEND_FN
  264. #define PHP_MN ZEND_MN
  265. #define PHP_NAMED_FUNCTION ZEND_NAMED_FUNCTION
  266. #define PHP_FUNCTION ZEND_FUNCTION
  267. #define PHP_METHOD ZEND_METHOD
  268. #define PHP_RAW_NAMED_FE ZEND_RAW_NAMED_FE
  269. #define PHP_NAMED_FE ZEND_NAMED_FE
  270. #define PHP_FE ZEND_FE
  271. #define PHP_DEP_FE ZEND_DEP_FE
  272. #define PHP_FALIAS ZEND_FALIAS
  273. #define PHP_DEP_FALIAS ZEND_DEP_FALIAS
  274. #define PHP_ME ZEND_ME
  275. #define PHP_MALIAS ZEND_MALIAS
  276. #define PHP_ABSTRACT_ME ZEND_ABSTRACT_ME
  277. #define PHP_ME_MAPPING ZEND_ME_MAPPING
  278. #define PHP_MODULE_STARTUP_N ZEND_MODULE_STARTUP_N
  279. #define PHP_MODULE_SHUTDOWN_N ZEND_MODULE_SHUTDOWN_N
  280. #define PHP_MODULE_ACTIVATE_N ZEND_MODULE_ACTIVATE_N
  281. #define PHP_MODULE_DEACTIVATE_N ZEND_MODULE_DEACTIVATE_N
  282. #define PHP_MODULE_INFO_N ZEND_MODULE_INFO_N
  283. #define PHP_MODULE_STARTUP_D ZEND_MODULE_STARTUP_D
  284. #define PHP_MODULE_SHUTDOWN_D ZEND_MODULE_SHUTDOWN_D
  285. #define PHP_MODULE_ACTIVATE_D ZEND_MODULE_ACTIVATE_D
  286. #define PHP_MODULE_DEACTIVATE_D ZEND_MODULE_DEACTIVATE_D
  287. #define PHP_MODULE_INFO_D ZEND_MODULE_INFO_D
  288. /* Compatibility macros */
  289. #define PHP_MINIT ZEND_MODULE_STARTUP_N
  290. #define PHP_MSHUTDOWN ZEND_MODULE_SHUTDOWN_N
  291. #define PHP_RINIT ZEND_MODULE_ACTIVATE_N
  292. #define PHP_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
  293. #define PHP_MINFO ZEND_MODULE_INFO_N
  294. #define PHP_GINIT ZEND_GINIT
  295. #define PHP_GSHUTDOWN ZEND_GSHUTDOWN
  296. #define PHP_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
  297. #define PHP_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
  298. #define PHP_RINIT_FUNCTION ZEND_MODULE_ACTIVATE_D
  299. #define PHP_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D
  300. #define PHP_MINFO_FUNCTION ZEND_MODULE_INFO_D
  301. #define PHP_GINIT_FUNCTION ZEND_GINIT_FUNCTION
  302. #define PHP_GSHUTDOWN_FUNCTION ZEND_GSHUTDOWN_FUNCTION
  303. #define PHP_MODULE_GLOBALS ZEND_MODULE_GLOBALS
  304. /* Output support */
  305. #include "main/php_output.h"
  306. #include "php_streams.h"
  307. #include "php_memory_streams.h"
  308. #include "fopen_wrappers.h"
  309. /* Virtual current working directory support */
  310. #include "tsrm_virtual_cwd.h"
  311. #include "zend_constants.h"
  312. /* connection status states */
  313. #define PHP_CONNECTION_NORMAL 0
  314. #define PHP_CONNECTION_ABORTED 1
  315. #define PHP_CONNECTION_TIMEOUT 2
  316. #include "php_reentrancy.h"
  317. /* Finding offsets of elements within structures.
  318. * Taken from the Apache code, which in turn, was taken from X code...
  319. */
  320. #ifndef XtOffset
  321. #if defined(CRAY) || (defined(__arm) && !(defined(LINUX) || defined(__riscos__)))
  322. #ifdef __STDC__
  323. #define XtOffset(p_type, field) _Offsetof(p_type, field)
  324. #else
  325. #ifdef CRAY2
  326. #define XtOffset(p_type, field) \
  327. (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
  328. #else /* !CRAY2 */
  329. #define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
  330. #endif /* !CRAY2 */
  331. #endif /* __STDC__ */
  332. #else /* ! (CRAY || __arm) */
  333. #define XtOffset(p_type, field) \
  334. ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
  335. #endif /* !CRAY */
  336. #endif /* ! XtOffset */
  337. #ifndef XtOffsetOf
  338. #ifdef offsetof
  339. #define XtOffsetOf(s_type, field) offsetof(s_type, field)
  340. #else
  341. #define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
  342. #endif
  343. #endif /* !XtOffsetOf */
  344. #endif
  345. /*
  346. * Local variables:
  347. * tab-width: 4
  348. * c-basic-offset: 4
  349. * End:
  350. * vim600: sw=4 ts=4 fdm=marker
  351. * vim<600: sw=4 ts=4
  352. */