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.

407 lines
10 KiB

27 years ago
25 years ago
27 years ago
25 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
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
25 years ago
27 years ago
27 years ago
27 years ago
27 years ago
27 years ago
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 4 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2002 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.02 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available at through the world-wide-web at |
  10. | http://www.php.net/license/2_02.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 20020307
  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. #if PHP_BROKEN_SPRINTF
  34. #undef sprintf
  35. #define sprintf php_sprintf
  36. #endif
  37. /* PHP's DEBUG value must match Zend's ZEND_DEBUG value */
  38. #undef PHP_DEBUG
  39. #define PHP_DEBUG ZEND_DEBUG
  40. #ifdef PHP_WIN32
  41. #include "tsrm_win32.h"
  42. #include "win95nt.h"
  43. # ifdef PHP_EXPORTS
  44. # define PHPAPI __declspec(dllexport)
  45. # else
  46. # define PHPAPI __declspec(dllimport)
  47. # endif
  48. #define PHP_DIR_SEPARATOR '\\'
  49. #else
  50. #define PHPAPI
  51. #define THREAD_LS
  52. #define PHP_DIR_SEPARATOR '/'
  53. #endif
  54. #ifdef NETWARE
  55. #define PHP_UNAME "NetWare" /* For php_get_uname() function */
  56. #define PHP_OS PHP_UNAME /* This is obtained using 'uname' on Unix and assigned in the case of Windows;
  57. we'll do it this way atleast for now */
  58. #endif
  59. #include "php_regex.h"
  60. #if HAVE_ASSERT_H
  61. #if PHP_DEBUG
  62. #undef NDEBUG
  63. #else
  64. #ifndef NDEBUG
  65. #define NDEBUG
  66. #endif
  67. #endif
  68. #include <assert.h>
  69. #else /* HAVE_ASSERT_H */
  70. #define assert(expr) ((void) (0))
  71. #endif /* HAVE_ASSERT_H */
  72. #define APACHE 0
  73. #if HAVE_UNIX_H
  74. #include <unix.h>
  75. #endif
  76. #if HAVE_ALLOCA_H
  77. #include <alloca.h>
  78. #endif
  79. /*
  80. * This is a fast version of strlcpy which should be used, if you
  81. * know the size of the destination buffer and if you know
  82. * the length of the source string.
  83. *
  84. * size is the allocated number of bytes of dst
  85. * src_size is the number of bytes excluding the NUL of src
  86. */
  87. #define PHP_STRLCPY(dst, src, size, src_size) \
  88. { \
  89. size_t php_str_len; \
  90. \
  91. if (src_size >= size) \
  92. php_str_len = size - 1; \
  93. else \
  94. php_str_len = src_size; \
  95. memcpy(dst, src, php_str_len); \
  96. dst[php_str_len] = '\0'; \
  97. }
  98. #ifndef HAVE_STRLCPY
  99. PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz);
  100. #define strlcpy php_strlcpy
  101. #endif
  102. #ifndef HAVE_STRLCAT
  103. PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz);
  104. #define strlcat php_strlcat
  105. #endif
  106. #ifndef HAVE_STRTOK_R
  107. char *strtok_r(char *s, const char *delim, char **last);
  108. #endif
  109. #ifndef HAVE_SOCKLEN_T
  110. typedef unsigned int socklen_t;
  111. #endif
  112. #define CREATE_MUTEX(a, b)
  113. #define SET_MUTEX(a)
  114. #define FREE_MUTEX(a)
  115. /*
  116. * Then the ODBC support can use both iodbc and Solid,
  117. * uncomment this.
  118. * #define HAVE_ODBC (HAVE_IODBC|HAVE_SOLID)
  119. */
  120. #include <stdlib.h>
  121. #include <ctype.h>
  122. #if HAVE_UNISTD_H
  123. #include <unistd.h>
  124. #endif
  125. #if HAVE_STDARG_H
  126. #include <stdarg.h>
  127. #else
  128. # if HAVE_SYS_VARARGS_H
  129. # include <sys/varargs.h>
  130. # endif
  131. #endif
  132. #include "zend_hash.h"
  133. #include "php3_compat.h"
  134. #include "zend_alloc.h"
  135. #include "zend_stack.h"
  136. #if STDC_HEADERS
  137. # include <string.h>
  138. #else
  139. # ifndef HAVE_MEMCPY
  140. # define memcpy(d, s, n) bcopy((s), (d), (n))
  141. # endif
  142. # ifndef HAVE_MEMMOVE
  143. # define memmove(d, s, n) bcopy ((s), (d), (n))
  144. # endif
  145. #endif
  146. #include "safe_mode.h"
  147. #ifndef HAVE_STRERROR
  148. char *strerror(int);
  149. #endif
  150. #if (REGEX == 1 || REGEX == 0) && !defined(NO_REGEX_EXTRA_H)
  151. #include "regex/regex_extra.h"
  152. #endif
  153. #if HAVE_PWD_H
  154. # ifdef PHP_WIN32
  155. #include "win32/pwd.h"
  156. #include "win32/param.h"
  157. #elif defined(NETWARE)
  158. #ifdef NEW_LIBC
  159. #include <sys/param.h>
  160. #else
  161. #include "NetWare/param.h"
  162. #endif
  163. #include "NetWare/pwd.h"
  164. # else
  165. #include <pwd.h>
  166. #include <sys/param.h>
  167. # endif
  168. #endif
  169. #if HAVE_LIMITS_H
  170. #include <limits.h>
  171. #endif
  172. #ifndef LONG_MAX
  173. #define LONG_MAX 2147483647L
  174. #endif
  175. #ifndef LONG_MIN
  176. #define LONG_MIN (- LONG_MAX - 1)
  177. #endif
  178. #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) || defined(BROKEN_SPRINTF) || defined(BROKEN_SNPRINTF) || defined(BROKEN_VSNPRINTF)
  179. #include "snprintf.h"
  180. #endif
  181. #include "spprintf.h"
  182. #define EXEC_INPUT_BUF 4096
  183. #define PHP_MIME_TYPE "application/x-httpd-php"
  184. /* macros */
  185. #define STR_PRINT(str) ((str)?(str):"")
  186. #ifndef MAXPATHLEN
  187. # ifdef PATH_MAX
  188. # define MAXPATHLEN PATH_MAX
  189. # else
  190. # define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
  191. # endif
  192. #endif
  193. /* global variables */
  194. extern pval *data;
  195. #if !defined(PHP_WIN32)
  196. #ifdef NETWARE
  197. #ifdef NEW_LIBC
  198. /*#undef environ*/ /* For now, so that our 'environ' implementation is used */
  199. #define php_sleep sleep
  200. #else
  201. #define php_sleep delay /* sleep() and usleep() are not available */
  202. #define usleep delay
  203. #endif
  204. extern char **environ;
  205. #else
  206. extern char **environ;
  207. #define php_sleep sleep
  208. #endif
  209. #endif
  210. #ifdef PHP_PWRITE_64
  211. ssize_t pwrite(int, void *, size_t, off64_t);
  212. #endif
  213. #ifdef PHP_PREAD_64
  214. ssize_t pread(int, void *, size_t, off64_t);
  215. #endif
  216. void phperror(char *error);
  217. PHPAPI int php_write(void *buf, uint size TSRMLS_DC);
  218. PHPAPI int php_printf(const char *format, ...);
  219. PHPAPI void php_log_err(char *log_message TSRMLS_DC);
  220. int Debug(char *format, ...);
  221. int cfgparse(void);
  222. #define php_error zend_error
  223. PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC) ;
  224. /* PHPAPI void php_error(int type, const char *format, ...); */
  225. PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...);
  226. PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, const char *format, ...);
  227. PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...);
  228. #define php_error_docref php_error_docref0
  229. #define zenderror phperror
  230. #define zendlex phplex
  231. #define phpparse zendparse
  232. #define phprestart zendrestart
  233. #define phpin zendin
  234. /* functions */
  235. int php_startup_internal_extensions(void);
  236. int php_mergesort(void *base, size_t nmemb, register size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC);
  237. PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
  238. PHPAPI int cfg_get_long(char *varname, long *result);
  239. PHPAPI int cfg_get_double(char *varname, double *result);
  240. PHPAPI int cfg_get_string(char *varname, char **result);
  241. /* PHP-named Zend macro wrappers */
  242. #define PHP_FN ZEND_FN
  243. #define PHP_NAMED_FUNCTION ZEND_NAMED_FUNCTION
  244. #define PHP_FUNCTION ZEND_FUNCTION
  245. #define PHP_NAMED_FE ZEND_NAMED_FE
  246. #define PHP_FE ZEND_FE
  247. #define PHP_FALIAS ZEND_FALIAS
  248. #define PHP_STATIC_FE ZEND_STATIC_FE
  249. #define PHP_MODULE_STARTUP_N ZEND_MODULE_STARTUP_N
  250. #define PHP_MODULE_SHUTDOWN_N ZEND_MODULE_SHUTDOWN_N
  251. #define PHP_MODULE_ACTIVATE_N ZEND_MODULE_ACTIVATE_N
  252. #define PHP_MODULE_DEACTIVATE_N ZEND_MODULE_DEACTIVATE_N
  253. #define PHP_MODULE_INFO_N ZEND_MODULE_INFO_N
  254. #define PHP_MODULE_STARTUP_D ZEND_MODULE_STARTUP_D
  255. #define PHP_MODULE_SHUTDOWN_D ZEND_MODULE_SHUTDOWN_D
  256. #define PHP_MODULE_ACTIVATE_D ZEND_MODULE_ACTIVATE_D
  257. #define PHP_MODULE_DEACTIVATE_D ZEND_MODULE_DEACTIVATE_D
  258. #define PHP_MODULE_INFO_D ZEND_MODULE_INFO_D
  259. /* Compatibility macros */
  260. #define PHP_MINIT ZEND_MODULE_STARTUP_N
  261. #define PHP_MSHUTDOWN ZEND_MODULE_SHUTDOWN_N
  262. #define PHP_RINIT ZEND_MODULE_ACTIVATE_N
  263. #define PHP_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
  264. #define PHP_MINFO ZEND_MODULE_INFO_N
  265. #define PHP_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
  266. #define PHP_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
  267. #define PHP_RINIT_FUNCTION ZEND_MODULE_ACTIVATE_D
  268. #define PHP_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D
  269. #define PHP_MINFO_FUNCTION ZEND_MODULE_INFO_D
  270. /* Output support */
  271. #include "main/php_output.h"
  272. #define PHPWRITE(str, str_len) php_body_write((str), (str_len) TSRMLS_CC)
  273. #define PUTS(str) php_body_write((str), strlen((str)) TSRMLS_CC)
  274. #define PUTC(c) (php_body_write(&(c), 1 TSRMLS_CC), (c))
  275. #define PHPWRITE_H(str, str_len) php_header_write((str), (str_len) TSRMLS_CC)
  276. #define PUTS_H(str) php_header_write((str), strlen((str)) TSRMLS_CC)
  277. #define PUTC_H(c) (php_header_write(&(c), 1 TSRMLS_CC), (c))
  278. #ifdef ZTS
  279. #define VIRTUAL_DIR
  280. #endif
  281. #include "php_streams.h"
  282. #include "php_memory_streams.h"
  283. #include "fopen_wrappers.h"
  284. /* Virtual current working directory support */
  285. #include "tsrm_virtual_cwd.h"
  286. #include "zend_constants.h"
  287. /* connection status states */
  288. #define PHP_CONNECTION_NORMAL 0
  289. #define PHP_CONNECTION_ABORTED 1
  290. #define PHP_CONNECTION_TIMEOUT 2
  291. #include "php_reentrancy.h"
  292. /* Finding offsets of elements within structures.
  293. * Taken from the Apache code, which in turn, was taken from X code...
  294. */
  295. #ifndef XtOffset
  296. #if defined(CRAY) || (defined(__arm) && !defined(LINUX))
  297. #ifdef __STDC__
  298. #define XtOffset(p_type, field) _Offsetof(p_type, field)
  299. #else
  300. #ifdef CRAY2
  301. #define XtOffset(p_type, field) \
  302. (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
  303. #else /* !CRAY2 */
  304. #define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
  305. #endif /* !CRAY2 */
  306. #endif /* __STDC__ */
  307. #else /* ! (CRAY || __arm) */
  308. #define XtOffset(p_type, field) \
  309. ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
  310. #endif /* !CRAY */
  311. #endif /* ! XtOffset */
  312. #ifndef XtOffsetOf
  313. #ifdef offsetof
  314. #define XtOffsetOf(s_type, field) offsetof(s_type, field)
  315. #else
  316. #define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
  317. #endif
  318. #endif /* !XtOffsetOf */
  319. #endif
  320. /*
  321. * Local variables:
  322. * tab-width: 4
  323. * c-basic-offset: 4
  324. * End:
  325. * vim600: sw=4 ts=4 fdm=marker
  326. * vim<600: sw=4 ts=4
  327. */