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.

458 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
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
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
25 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2004 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.0 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_0.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 20041225
  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. #define PHPAPI
  50. #define THREAD_LS
  51. #define PHP_DIR_SEPARATOR '/'
  52. #if defined(__MacOSX__)
  53. #define PHP_EOL "\r"
  54. #else
  55. #define PHP_EOL "\n"
  56. #endif
  57. #endif
  58. #ifdef NETWARE
  59. /* For php_get_uname() function */
  60. #define PHP_UNAME "NetWare"
  61. #define PHP_OS PHP_UNAME
  62. #endif
  63. #include "php_regex.h"
  64. #if HAVE_ASSERT_H
  65. #if PHP_DEBUG
  66. #undef NDEBUG
  67. #else
  68. #ifndef NDEBUG
  69. #define NDEBUG
  70. #endif
  71. #endif
  72. #include <assert.h>
  73. #else /* HAVE_ASSERT_H */
  74. #define assert(expr) ((void) (0))
  75. #endif /* HAVE_ASSERT_H */
  76. #define APACHE 0
  77. #if HAVE_UNIX_H
  78. #include <unix.h>
  79. #endif
  80. #if HAVE_ALLOCA_H
  81. #include <alloca.h>
  82. #endif
  83. #if HAVE_BUILD_DEFS_H
  84. #include <build-defs.h>
  85. #endif
  86. /*
  87. * This is a fast version of strlcpy which should be used, if you
  88. * know the size of the destination buffer and if you know
  89. * the length of the source string.
  90. *
  91. * size is the allocated number of bytes of dst
  92. * src_size is the number of bytes excluding the NUL of src
  93. */
  94. #define PHP_STRLCPY(dst, src, size, src_size) \
  95. { \
  96. size_t php_str_len; \
  97. \
  98. if (src_size >= size) \
  99. php_str_len = size - 1; \
  100. else \
  101. php_str_len = src_size; \
  102. memcpy(dst, src, php_str_len); \
  103. dst[php_str_len] = '\0'; \
  104. }
  105. #ifndef HAVE_STRLCPY
  106. BEGIN_EXTERN_C()
  107. PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz);
  108. END_EXTERN_C()
  109. #undef strlcpy
  110. #define strlcpy php_strlcpy
  111. #endif
  112. #ifndef HAVE_STRLCAT
  113. BEGIN_EXTERN_C()
  114. PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz);
  115. END_EXTERN_C()
  116. #undef strlcat
  117. #define strlcat php_strlcat
  118. #endif
  119. #ifndef HAVE_STRTOK_R
  120. BEGIN_EXTERN_C()
  121. char *strtok_r(char *s, const char *delim, char **last);
  122. END_EXTERN_C()
  123. #endif
  124. #ifndef HAVE_SOCKLEN_T
  125. typedef unsigned int socklen_t;
  126. #endif
  127. #define CREATE_MUTEX(a, b)
  128. #define SET_MUTEX(a)
  129. #define FREE_MUTEX(a)
  130. /*
  131. * Then the ODBC support can use both iodbc and Solid,
  132. * uncomment this.
  133. * #define HAVE_ODBC (HAVE_IODBC|HAVE_SOLID)
  134. */
  135. #include <stdlib.h>
  136. #include <ctype.h>
  137. #if HAVE_UNISTD_H
  138. #include <unistd.h>
  139. #endif
  140. #if HAVE_STDARG_H
  141. #include <stdarg.h>
  142. #else
  143. # if HAVE_SYS_VARARGS_H
  144. # include <sys/varargs.h>
  145. # endif
  146. #endif
  147. #include "zend_hash.h"
  148. #include "php3_compat.h"
  149. #include "zend_alloc.h"
  150. #include "zend_stack.h"
  151. #if STDC_HEADERS
  152. # include <string.h>
  153. #else
  154. # ifndef HAVE_MEMCPY
  155. # define memcpy(d, s, n) bcopy((s), (d), (n))
  156. # endif
  157. # ifndef HAVE_MEMMOVE
  158. # define memmove(d, s, n) bcopy ((s), (d), (n))
  159. # endif
  160. #endif
  161. #include "safe_mode.h"
  162. #ifndef HAVE_STRERROR
  163. char *strerror(int);
  164. #endif
  165. #if (REGEX == 1 || REGEX == 0) && !defined(NO_REGEX_EXTRA_H)
  166. #include "regex/regex_extra.h"
  167. #endif
  168. #if HAVE_PWD_H
  169. # ifdef PHP_WIN32
  170. #include "win32/pwd.h"
  171. #include "win32/param.h"
  172. #elif defined(NETWARE)
  173. #include <sys/param.h>
  174. #include "NetWare/pwd.h"
  175. # else
  176. #include <pwd.h>
  177. #include <sys/param.h>
  178. # endif
  179. #endif
  180. #if HAVE_LIMITS_H
  181. #include <limits.h>
  182. #endif
  183. #ifndef LONG_MAX
  184. #define LONG_MAX 2147483647L
  185. #endif
  186. #ifndef LONG_MIN
  187. #define LONG_MIN (- LONG_MAX - 1)
  188. #endif
  189. #ifndef INT_MAX
  190. #define INT_MAX 2147483647
  191. #endif
  192. #ifndef INT_MIN
  193. #define INT_MIN (- INT_MAX - 1)
  194. #endif
  195. #define PHP_GCC_VERSION ZEND_GCC_VERSION
  196. #define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC
  197. #define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT
  198. BEGIN_EXTERN_C()
  199. #include "snprintf.h"
  200. END_EXTERN_C()
  201. #include "spprintf.h"
  202. #define EXEC_INPUT_BUF 4096
  203. #define PHP_MIME_TYPE "application/x-httpd-php"
  204. /* macros */
  205. #define STR_PRINT(str) ((str)?(str):"")
  206. #ifndef MAXPATHLEN
  207. # ifdef PATH_MAX
  208. # define MAXPATHLEN PATH_MAX
  209. # else
  210. # define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
  211. # endif
  212. #endif
  213. /* global variables */
  214. extern pval *data;
  215. #if !defined(PHP_WIN32)
  216. #define PHP_SLEEP_NON_VOID
  217. #define php_sleep sleep
  218. extern char **environ;
  219. #endif /* !defined(PHP_WIN32) */
  220. #ifdef PHP_PWRITE_64
  221. ssize_t pwrite(int, void *, size_t, off64_t);
  222. #endif
  223. #ifdef PHP_PREAD_64
  224. ssize_t pread(int, void *, size_t, off64_t);
  225. #endif
  226. BEGIN_EXTERN_C()
  227. void phperror(char *error);
  228. PHPAPI int php_write(void *buf, uint size TSRMLS_DC);
  229. PHPAPI int php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
  230. 2);
  231. PHPAPI void php_log_err(char *log_message TSRMLS_DC);
  232. int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
  233. int cfgparse(void);
  234. END_EXTERN_C()
  235. #define php_error zend_error
  236. typedef enum {
  237. EH_NORMAL = 0,
  238. EH_SUPPRESS,
  239. EH_THROW
  240. } error_handling_t;
  241. BEGIN_EXTERN_C()
  242. PHPAPI void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC);
  243. #define php_std_error_handling() php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC)
  244. 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);
  245. #ifdef ZTS
  246. #define PHP_ATTR_FMT_OFFSET 1
  247. #else
  248. #define PHP_ATTR_FMT_OFFSET 0
  249. #endif
  250. /* PHPAPI void php_error(int type, const char *format, ...); */
  251. PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...)
  252. PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 3, PHP_ATTR_FMT_OFFSET + 4);
  253. PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, const char *format, ...)
  254. PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 4, PHP_ATTR_FMT_OFFSET + 5);
  255. PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...)
  256. PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 5, PHP_ATTR_FMT_OFFSET + 6);
  257. END_EXTERN_C()
  258. #define php_error_docref php_error_docref0
  259. #define zenderror phperror
  260. #define zendlex phplex
  261. #define phpparse zendparse
  262. #define phprestart zendrestart
  263. #define phpin zendin
  264. #define php_memnstr zend_memnstr
  265. /* functions */
  266. BEGIN_EXTERN_C()
  267. int php_startup_internal_extensions(void);
  268. int php_mergesort(void *base, size_t nmemb, register size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC);
  269. PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
  270. PHPAPI int cfg_get_long(char *varname, long *result);
  271. PHPAPI int cfg_get_double(char *varname, double *result);
  272. PHPAPI int cfg_get_string(char *varname, char **result);
  273. END_EXTERN_C()
  274. /* PHP-named Zend macro wrappers */
  275. #define PHP_FN ZEND_FN
  276. #define PHP_NAMED_FUNCTION ZEND_NAMED_FUNCTION
  277. #define PHP_FUNCTION ZEND_FUNCTION
  278. #define PHP_METHOD ZEND_METHOD
  279. #define PHP_NAMED_FE ZEND_NAMED_FE
  280. #define PHP_FE ZEND_FE
  281. #define PHP_FALIAS ZEND_FALIAS
  282. #define PHP_ME ZEND_ME
  283. #define PHP_MALIAS ZEND_MALIAS
  284. #define PHP_ME_MAPPING ZEND_ME_MAPPING
  285. #define PHP_MODULE_STARTUP_N ZEND_MODULE_STARTUP_N
  286. #define PHP_MODULE_SHUTDOWN_N ZEND_MODULE_SHUTDOWN_N
  287. #define PHP_MODULE_ACTIVATE_N ZEND_MODULE_ACTIVATE_N
  288. #define PHP_MODULE_DEACTIVATE_N ZEND_MODULE_DEACTIVATE_N
  289. #define PHP_MODULE_INFO_N ZEND_MODULE_INFO_N
  290. #define PHP_MODULE_STARTUP_D ZEND_MODULE_STARTUP_D
  291. #define PHP_MODULE_SHUTDOWN_D ZEND_MODULE_SHUTDOWN_D
  292. #define PHP_MODULE_ACTIVATE_D ZEND_MODULE_ACTIVATE_D
  293. #define PHP_MODULE_DEACTIVATE_D ZEND_MODULE_DEACTIVATE_D
  294. #define PHP_MODULE_INFO_D ZEND_MODULE_INFO_D
  295. /* Compatibility macros */
  296. #define PHP_MINIT ZEND_MODULE_STARTUP_N
  297. #define PHP_MSHUTDOWN ZEND_MODULE_SHUTDOWN_N
  298. #define PHP_RINIT ZEND_MODULE_ACTIVATE_N
  299. #define PHP_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
  300. #define PHP_MINFO ZEND_MODULE_INFO_N
  301. #define PHP_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
  302. #define PHP_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
  303. #define PHP_RINIT_FUNCTION ZEND_MODULE_ACTIVATE_D
  304. #define PHP_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D
  305. #define PHP_MINFO_FUNCTION ZEND_MODULE_INFO_D
  306. /* Output support */
  307. #include "main/php_output.h"
  308. #define PHPWRITE(str, str_len) php_body_write((str), (str_len) TSRMLS_CC)
  309. #define PUTS(str) do { \
  310. const char *__str = (str); \
  311. php_body_write(__str, strlen(__str) TSRMLS_CC); \
  312. } while (0)
  313. #define PUTC(c) (php_body_write(&(c), 1 TSRMLS_CC), (c))
  314. #define PHPWRITE_H(str, str_len) php_header_write((str), (str_len) TSRMLS_CC)
  315. #define PUTS_H(str) do { \
  316. const char *__str = (str); \
  317. php_header_write(__str, strlen(__str) TSRMLS_CC); \
  318. } while (0)
  319. #define PUTC_H(c) (php_header_write(&(c), 1 TSRMLS_CC), (c))
  320. #ifdef ZTS
  321. #define VIRTUAL_DIR
  322. #endif
  323. #include "php_streams.h"
  324. #include "php_memory_streams.h"
  325. #include "fopen_wrappers.h"
  326. /* Virtual current working directory support */
  327. #include "tsrm_virtual_cwd.h"
  328. #include "zend_constants.h"
  329. /* connection status states */
  330. #define PHP_CONNECTION_NORMAL 0
  331. #define PHP_CONNECTION_ABORTED 1
  332. #define PHP_CONNECTION_TIMEOUT 2
  333. #include "php_reentrancy.h"
  334. /* Finding offsets of elements within structures.
  335. * Taken from the Apache code, which in turn, was taken from X code...
  336. */
  337. #ifndef XtOffset
  338. #if defined(CRAY) || (defined(__arm) && !defined(LINUX))
  339. #ifdef __STDC__
  340. #define XtOffset(p_type, field) _Offsetof(p_type, field)
  341. #else
  342. #ifdef CRAY2
  343. #define XtOffset(p_type, field) \
  344. (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
  345. #else /* !CRAY2 */
  346. #define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
  347. #endif /* !CRAY2 */
  348. #endif /* __STDC__ */
  349. #else /* ! (CRAY || __arm) */
  350. #define XtOffset(p_type, field) \
  351. ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
  352. #endif /* !CRAY */
  353. #endif /* ! XtOffset */
  354. #ifndef XtOffsetOf
  355. #ifdef offsetof
  356. #define XtOffsetOf(s_type, field) offsetof(s_type, field)
  357. #else
  358. #define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
  359. #endif
  360. #endif /* !XtOffsetOf */
  361. #endif
  362. /*
  363. * Local variables:
  364. * tab-width: 4
  365. * c-basic-offset: 4
  366. * End:
  367. * vim600: sw=4 ts=4 fdm=marker
  368. * vim<600: sw=4 ts=4
  369. */