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.

461 lines
12 KiB

27 years ago
27 years ago
15 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
21 years ago
21 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
21 years ago
27 years ago
25 years ago
27 years ago
21 years ago
27 years ago
27 years ago
27 years ago
27 years ago
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2011 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 20100412
  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. # if PHP_WIN32
  129. typedef int socklen_t;
  130. # else
  131. typedef unsigned int socklen_t;
  132. # endif
  133. #endif
  134. #define CREATE_MUTEX(a, b)
  135. #define SET_MUTEX(a)
  136. #define FREE_MUTEX(a)
  137. /*
  138. * Then the ODBC support can use both iodbc and Solid,
  139. * uncomment this.
  140. * #define HAVE_ODBC (HAVE_IODBC|HAVE_SOLID)
  141. */
  142. #include <stdlib.h>
  143. #include <ctype.h>
  144. #if HAVE_UNISTD_H
  145. #include <unistd.h>
  146. #endif
  147. #if HAVE_STDARG_H
  148. #include <stdarg.h>
  149. #else
  150. # if HAVE_SYS_VARARGS_H
  151. # include <sys/varargs.h>
  152. # endif
  153. #endif
  154. #ifndef va_copy
  155. # ifdef __va_copy
  156. # define va_copy(ap1, ap2) __va_copy((ap1), (ap2))
  157. # else
  158. # define va_copy(ap1, ap2) memcpy((&ap1), (&ap2), sizeof(va_list))
  159. # endif
  160. #endif
  161. #include "zend_hash.h"
  162. #include "zend_alloc.h"
  163. #include "zend_stack.h"
  164. #if STDC_HEADERS
  165. # include <string.h>
  166. #else
  167. # ifndef HAVE_MEMCPY
  168. # define memcpy(d, s, n) bcopy((s), (d), (n))
  169. # endif
  170. # ifndef HAVE_MEMMOVE
  171. # define memmove(d, s, n) bcopy ((s), (d), (n))
  172. # endif
  173. #endif
  174. #ifndef HAVE_STRERROR
  175. char *strerror(int);
  176. #endif
  177. #if HAVE_PWD_H
  178. # ifdef PHP_WIN32
  179. #include "win32/param.h"
  180. # else
  181. #include <pwd.h>
  182. #include <sys/param.h>
  183. # endif
  184. #endif
  185. #if HAVE_LIMITS_H
  186. #include <limits.h>
  187. #endif
  188. #ifndef LONG_MAX
  189. #define LONG_MAX 2147483647L
  190. #endif
  191. #ifndef LONG_MIN
  192. #define LONG_MIN (- LONG_MAX - 1)
  193. #endif
  194. #ifndef INT_MAX
  195. #define INT_MAX 2147483647
  196. #endif
  197. #ifndef INT_MIN
  198. #define INT_MIN (- INT_MAX - 1)
  199. #endif
  200. #define PHP_GCC_VERSION ZEND_GCC_VERSION
  201. #define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC
  202. #define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT
  203. BEGIN_EXTERN_C()
  204. #include "snprintf.h"
  205. END_EXTERN_C()
  206. #include "spprintf.h"
  207. #define EXEC_INPUT_BUF 4096
  208. #define PHP_MIME_TYPE "application/x-httpd-php"
  209. /* macros */
  210. #define STR_PRINT(str) ((str)?(str):"")
  211. #ifndef MAXPATHLEN
  212. # ifdef PATH_MAX
  213. # define MAXPATHLEN PATH_MAX
  214. # elif defined(MAX_PATH)
  215. # define MAXPATHLEN MAX_PATH
  216. # else
  217. # define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
  218. # endif
  219. #endif
  220. #if defined(__GNUC__) && __GNUC__ >= 4
  221. # define php_ignore_value(x) (({ __typeof__ (x) __x = (x); (void) __x; }))
  222. #else
  223. # define php_ignore_value(x) ((void) (x))
  224. #endif
  225. /* global variables */
  226. #if !defined(PHP_WIN32)
  227. #define PHP_SLEEP_NON_VOID
  228. #define php_sleep sleep
  229. extern char **environ;
  230. #endif /* !defined(PHP_WIN32) */
  231. #ifdef PHP_PWRITE_64
  232. ssize_t pwrite(int, void *, size_t, off64_t);
  233. #endif
  234. #ifdef PHP_PREAD_64
  235. ssize_t pread(int, void *, size_t, off64_t);
  236. #endif
  237. BEGIN_EXTERN_C()
  238. void phperror(char *error);
  239. PHPAPI int php_write(void *buf, uint size TSRMLS_DC);
  240. PHPAPI int php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
  241. 2);
  242. PHPAPI int php_get_module_initialized(void);
  243. PHPAPI void php_log_err(char *log_message TSRMLS_DC);
  244. int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
  245. int cfgparse(void);
  246. END_EXTERN_C()
  247. #define php_error zend_error
  248. #define error_handling_t zend_error_handling_t
  249. BEGIN_EXTERN_C()
  250. static inline ZEND_ATTRIBUTE_DEPRECATED void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC)
  251. {
  252. zend_replace_error_handling(error_handling, exception_class, NULL TSRMLS_CC);
  253. }
  254. static inline ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling() {}
  255. 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);
  256. #ifdef ZTS
  257. #define PHP_ATTR_FMT_OFFSET 1
  258. #else
  259. #define PHP_ATTR_FMT_OFFSET 0
  260. #endif
  261. /* PHPAPI void php_error(int type, const char *format, ...); */
  262. PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...)
  263. PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 3, PHP_ATTR_FMT_OFFSET + 4);
  264. PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, const char *format, ...)
  265. PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 4, PHP_ATTR_FMT_OFFSET + 5);
  266. PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...)
  267. PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 5, PHP_ATTR_FMT_OFFSET + 6);
  268. #ifdef PHP_WIN32
  269. PHPAPI void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2 TSRMLS_DC);
  270. #endif
  271. END_EXTERN_C()
  272. #define php_error_docref php_error_docref0
  273. #define zenderror phperror
  274. #define zendlex phplex
  275. #define phpparse zendparse
  276. #define phprestart zendrestart
  277. #define phpin zendin
  278. #define php_memnstr zend_memnstr
  279. /* functions */
  280. BEGIN_EXTERN_C()
  281. PHPAPI extern int (*php_register_internal_extensions_func)(TSRMLS_D);
  282. PHPAPI int php_register_internal_extensions(TSRMLS_D);
  283. PHPAPI int php_mergesort(void *base, size_t nmemb, register size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC);
  284. PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
  285. PHPAPI void php_com_initialize(TSRMLS_D);
  286. PHPAPI char *php_get_current_user(TSRMLS_D);
  287. END_EXTERN_C()
  288. /* PHP-named Zend macro wrappers */
  289. #define PHP_FN ZEND_FN
  290. #define PHP_MN ZEND_MN
  291. #define PHP_NAMED_FUNCTION ZEND_NAMED_FUNCTION
  292. #define PHP_FUNCTION ZEND_FUNCTION
  293. #define PHP_METHOD ZEND_METHOD
  294. #define PHP_RAW_NAMED_FE ZEND_RAW_NAMED_FE
  295. #define PHP_NAMED_FE ZEND_NAMED_FE
  296. #define PHP_FE ZEND_FE
  297. #define PHP_DEP_FE ZEND_DEP_FE
  298. #define PHP_FALIAS ZEND_FALIAS
  299. #define PHP_DEP_FALIAS ZEND_DEP_FALIAS
  300. #define PHP_ME ZEND_ME
  301. #define PHP_MALIAS ZEND_MALIAS
  302. #define PHP_ABSTRACT_ME ZEND_ABSTRACT_ME
  303. #define PHP_ME_MAPPING ZEND_ME_MAPPING
  304. #define PHP_FE_END ZEND_FE_END
  305. #define PHP_MODULE_STARTUP_N ZEND_MODULE_STARTUP_N
  306. #define PHP_MODULE_SHUTDOWN_N ZEND_MODULE_SHUTDOWN_N
  307. #define PHP_MODULE_ACTIVATE_N ZEND_MODULE_ACTIVATE_N
  308. #define PHP_MODULE_DEACTIVATE_N ZEND_MODULE_DEACTIVATE_N
  309. #define PHP_MODULE_INFO_N ZEND_MODULE_INFO_N
  310. #define PHP_MODULE_STARTUP_D ZEND_MODULE_STARTUP_D
  311. #define PHP_MODULE_SHUTDOWN_D ZEND_MODULE_SHUTDOWN_D
  312. #define PHP_MODULE_ACTIVATE_D ZEND_MODULE_ACTIVATE_D
  313. #define PHP_MODULE_DEACTIVATE_D ZEND_MODULE_DEACTIVATE_D
  314. #define PHP_MODULE_INFO_D ZEND_MODULE_INFO_D
  315. /* Compatibility macros */
  316. #define PHP_MINIT ZEND_MODULE_STARTUP_N
  317. #define PHP_MSHUTDOWN ZEND_MODULE_SHUTDOWN_N
  318. #define PHP_RINIT ZEND_MODULE_ACTIVATE_N
  319. #define PHP_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
  320. #define PHP_MINFO ZEND_MODULE_INFO_N
  321. #define PHP_GINIT ZEND_GINIT
  322. #define PHP_GSHUTDOWN ZEND_GSHUTDOWN
  323. #define PHP_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
  324. #define PHP_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
  325. #define PHP_RINIT_FUNCTION ZEND_MODULE_ACTIVATE_D
  326. #define PHP_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D
  327. #define PHP_MINFO_FUNCTION ZEND_MODULE_INFO_D
  328. #define PHP_GINIT_FUNCTION ZEND_GINIT_FUNCTION
  329. #define PHP_GSHUTDOWN_FUNCTION ZEND_GSHUTDOWN_FUNCTION
  330. #define PHP_MODULE_GLOBALS ZEND_MODULE_GLOBALS
  331. /* Output support */
  332. #include "main/php_output.h"
  333. #include "php_streams.h"
  334. #include "php_memory_streams.h"
  335. #include "fopen_wrappers.h"
  336. /* Virtual current working directory support */
  337. #include "tsrm_virtual_cwd.h"
  338. #include "zend_constants.h"
  339. /* connection status states */
  340. #define PHP_CONNECTION_NORMAL 0
  341. #define PHP_CONNECTION_ABORTED 1
  342. #define PHP_CONNECTION_TIMEOUT 2
  343. #include "php_reentrancy.h"
  344. /* Finding offsets of elements within structures.
  345. * Taken from the Apache code, which in turn, was taken from X code...
  346. */
  347. #ifndef XtOffset
  348. #if defined(CRAY) || (defined(__arm) && !(defined(LINUX) || defined(__riscos__)))
  349. #ifdef __STDC__
  350. #define XtOffset(p_type, field) _Offsetof(p_type, field)
  351. #else
  352. #ifdef CRAY2
  353. #define XtOffset(p_type, field) \
  354. (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
  355. #else /* !CRAY2 */
  356. #define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
  357. #endif /* !CRAY2 */
  358. #endif /* __STDC__ */
  359. #else /* ! (CRAY || __arm) */
  360. #define XtOffset(p_type, field) \
  361. ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
  362. #endif /* !CRAY */
  363. #endif /* ! XtOffset */
  364. #ifndef XtOffsetOf
  365. #ifdef offsetof
  366. #define XtOffsetOf(s_type, field) offsetof(s_type, field)
  367. #else
  368. #define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
  369. #endif
  370. #endif /* !XtOffsetOf */
  371. #endif
  372. /*
  373. * Local variables:
  374. * tab-width: 4
  375. * c-basic-offset: 4
  376. * End:
  377. * vim600: sw=4 ts=4 fdm=marker
  378. * vim<600: sw=4 ts=4
  379. */