php.h 12 KB

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