PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/runtime/ext_zend_compat/php-src/main/php.h

https://github.com/tstarling/hiphop-php
C Header | 456 lines | 321 code | 81 blank | 54 comment | 10 complexity | bc2120ac89c6c9b708d231c72cbd1221 MD5 | raw file
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2013 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 20121113
  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. # define PHP_EOL "\n"
  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. #if HAVE_ASSERT_H
  64. #if PHP_DEBUG
  65. #undef NDEBUG
  66. #else
  67. #ifndef NDEBUG
  68. #define NDEBUG
  69. #endif
  70. #endif
  71. #include <assert.h>
  72. #else /* HAVE_ASSERT_H */
  73. #define assert(expr) ((void) (0))
  74. #endif /* HAVE_ASSERT_H */
  75. #define APACHE 0
  76. #if HAVE_UNIX_H
  77. #include <unix.h>
  78. #endif
  79. #if HAVE_ALLOCA_H
  80. #include <alloca.h>
  81. #endif
  82. #if HAVE_BUILD_DEFS_H
  83. #include <build-defs.h>
  84. #endif
  85. /*
  86. * This is a fast version of strlcpy which should be used, if you
  87. * know the size of the destination buffer and if you know
  88. * the length of the source string.
  89. *
  90. * size is the allocated number of bytes of dst
  91. * src_size is the number of bytes excluding the NUL of src
  92. */
  93. #define PHP_STRLCPY(dst, src, size, src_size) \
  94. { \
  95. size_t php_str_len; \
  96. \
  97. if (src_size >= size) \
  98. php_str_len = size - 1; \
  99. else \
  100. php_str_len = src_size; \
  101. memcpy(dst, src, php_str_len); \
  102. dst[php_str_len] = '\0'; \
  103. }
  104. #ifndef HAVE_STRLCPY
  105. BEGIN_EXTERN_C()
  106. PHPAPI size_t php_strlcpy(char *dst, const char *src, size_t siz);
  107. END_EXTERN_C()
  108. #undef strlcpy
  109. #define strlcpy php_strlcpy
  110. #endif
  111. #ifndef HAVE_STRLCAT
  112. BEGIN_EXTERN_C()
  113. PHPAPI size_t php_strlcat(char *dst, const char *src, size_t siz);
  114. END_EXTERN_C()
  115. #undef strlcat
  116. #define strlcat php_strlcat
  117. #endif
  118. #ifndef HAVE_STRTOK_R
  119. BEGIN_EXTERN_C()
  120. char *strtok_r(char *s, const char *delim, char **last);
  121. END_EXTERN_C()
  122. #endif
  123. #ifndef HAVE_SOCKLEN_T
  124. # if PHP_WIN32
  125. typedef int socklen_t;
  126. # else
  127. typedef unsigned int socklen_t;
  128. # endif
  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. #ifndef va_copy
  151. # ifdef __va_copy
  152. # define va_copy(ap1, ap2) __va_copy((ap1), (ap2))
  153. # else
  154. # define va_copy(ap1, ap2) memcpy((&ap1), (&ap2), sizeof(va_list))
  155. # endif
  156. #endif
  157. #include "zend_hash.h"
  158. #include "zend_alloc.h"
  159. #include "zend_stack.h"
  160. #if STDC_HEADERS
  161. # include <string.h>
  162. #else
  163. # ifndef HAVE_MEMCPY
  164. # define memcpy(d, s, n) bcopy((s), (d), (n))
  165. # endif
  166. # ifndef HAVE_MEMMOVE
  167. # define memmove(d, s, n) bcopy ((s), (d), (n))
  168. # endif
  169. #endif
  170. #ifndef HAVE_STRERROR
  171. char *strerror(int);
  172. #endif
  173. #if HAVE_PWD_H
  174. # ifdef PHP_WIN32
  175. #include <win32/param.h>
  176. # else
  177. #include <pwd.h>
  178. #include <sys/param.h>
  179. # endif
  180. #endif
  181. #if HAVE_LIMITS_H
  182. #include <limits.h>
  183. #endif
  184. #ifndef LONG_MAX
  185. #define LONG_MAX 2147483647L
  186. #endif
  187. #ifndef LONG_MIN
  188. #define LONG_MIN (- LONG_MAX - 1)
  189. #endif
  190. #ifndef INT_MAX
  191. #define INT_MAX 2147483647
  192. #endif
  193. #ifndef INT_MIN
  194. #define INT_MIN (- INT_MAX - 1)
  195. #endif
  196. #define PHP_GCC_VERSION ZEND_GCC_VERSION
  197. #define PHP_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_MALLOC
  198. #define PHP_ATTRIBUTE_FORMAT ZEND_ATTRIBUTE_FORMAT
  199. BEGIN_EXTERN_C()
  200. #include "snprintf.h"
  201. END_EXTERN_C()
  202. #include "spprintf.h"
  203. #define EXEC_INPUT_BUF 4096
  204. #define PHP_MIME_TYPE "application/x-httpd-php"
  205. /* macros */
  206. #define STR_PRINT(str) ((str)?(str):"")
  207. #ifndef MAXPATHLEN
  208. # ifdef PATH_MAX
  209. # define MAXPATHLEN PATH_MAX
  210. # elif defined(MAX_PATH)
  211. # define MAXPATHLEN MAX_PATH
  212. # else
  213. # define MAXPATHLEN 256 /* Should be safe for any weird systems that do not define it */
  214. # endif
  215. #endif
  216. #if defined(__GNUC__) && __GNUC__ >= 4
  217. # define php_ignore_value(x) (({ __typeof__ (x) __x = (x); (void) __x; }))
  218. #else
  219. # define php_ignore_value(x) ((void) (x))
  220. #endif
  221. /* global variables */
  222. #if !defined(PHP_WIN32)
  223. #define PHP_SLEEP_NON_VOID
  224. #define php_sleep sleep
  225. extern char **environ;
  226. #endif /* !defined(PHP_WIN32) */
  227. #ifdef PHP_PWRITE_64
  228. ssize_t pwrite(int, void *, size_t, off64_t);
  229. #endif
  230. #ifdef PHP_PREAD_64
  231. ssize_t pread(int, void *, size_t, off64_t);
  232. #endif
  233. BEGIN_EXTERN_C()
  234. void phperror(char *error);
  235. PHPAPI int php_write(void *buf, uint size TSRMLS_DC);
  236. PHPAPI int php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
  237. 2);
  238. PHPAPI int php_get_module_initialized(void);
  239. PHPAPI void php_log_err(char *log_message TSRMLS_DC);
  240. int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
  241. int cfgparse(void);
  242. END_EXTERN_C()
  243. #define php_error zend_error
  244. #define error_handling_t zend_error_handling_t
  245. BEGIN_EXTERN_C()
  246. static inline ZEND_ATTRIBUTE_DEPRECATED void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC)
  247. {
  248. zend_replace_error_handling(error_handling, exception_class, NULL TSRMLS_CC);
  249. }
  250. static inline ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling() {}
  251. 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);
  252. #ifdef ZTS
  253. #define PHP_ATTR_FMT_OFFSET 1
  254. #else
  255. #define PHP_ATTR_FMT_OFFSET 0
  256. #endif
  257. /* PHPAPI void php_error(int type, const char *format, ...); */
  258. PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...)
  259. PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 3, PHP_ATTR_FMT_OFFSET + 4);
  260. PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, const char *format, ...)
  261. PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 4, PHP_ATTR_FMT_OFFSET + 5);
  262. PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...)
  263. PHP_ATTRIBUTE_FORMAT(printf, PHP_ATTR_FMT_OFFSET + 5, PHP_ATTR_FMT_OFFSET + 6);
  264. #ifdef PHP_WIN32
  265. PHPAPI void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2 TSRMLS_DC);
  266. #endif
  267. END_EXTERN_C()
  268. #define php_error_docref php_error_docref0
  269. #define zenderror phperror
  270. #define zendlex phplex
  271. #define phpparse zendparse
  272. #define phprestart zendrestart
  273. #define phpin zendin
  274. #define php_memnstr zend_memnstr
  275. /* functions */
  276. BEGIN_EXTERN_C()
  277. PHPAPI extern int (*php_register_internal_extensions_func)(TSRMLS_D);
  278. PHPAPI int php_register_internal_extensions(TSRMLS_D);
  279. PHPAPI int php_mergesort(void *base, size_t nmemb, register size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC);
  280. PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
  281. PHPAPI void php_com_initialize(TSRMLS_D);
  282. PHPAPI char *php_get_current_user(TSRMLS_D);
  283. END_EXTERN_C()
  284. /* PHP-named Zend macro wrappers */
  285. #define PHP_FN ZEND_FN
  286. #define PHP_MN ZEND_MN
  287. #define PHP_NAMED_FUNCTION ZEND_NAMED_FUNCTION
  288. #define PHP_FUNCTION ZEND_FUNCTION
  289. #define PHP_METHOD ZEND_METHOD
  290. #define PHP_RAW_NAMED_FE ZEND_RAW_NAMED_FE
  291. #define PHP_NAMED_FE ZEND_NAMED_FE
  292. #define PHP_FE ZEND_FE
  293. #define PHP_DEP_FE ZEND_DEP_FE
  294. #define PHP_FALIAS ZEND_FALIAS
  295. #define PHP_DEP_FALIAS ZEND_DEP_FALIAS
  296. #define PHP_ME ZEND_ME
  297. #define PHP_MALIAS ZEND_MALIAS
  298. #define PHP_ABSTRACT_ME ZEND_ABSTRACT_ME
  299. #define PHP_ME_MAPPING ZEND_ME_MAPPING
  300. #define PHP_FE_END ZEND_FE_END
  301. #define PHP_MODULE_STARTUP_N ZEND_MODULE_STARTUP_N
  302. #define PHP_MODULE_SHUTDOWN_N ZEND_MODULE_SHUTDOWN_N
  303. #define PHP_MODULE_ACTIVATE_N ZEND_MODULE_ACTIVATE_N
  304. #define PHP_MODULE_DEACTIVATE_N ZEND_MODULE_DEACTIVATE_N
  305. #define PHP_MODULE_INFO_N ZEND_MODULE_INFO_N
  306. #define PHP_MODULE_STARTUP_D ZEND_MODULE_STARTUP_D
  307. #define PHP_MODULE_SHUTDOWN_D ZEND_MODULE_SHUTDOWN_D
  308. #define PHP_MODULE_ACTIVATE_D ZEND_MODULE_ACTIVATE_D
  309. #define PHP_MODULE_DEACTIVATE_D ZEND_MODULE_DEACTIVATE_D
  310. #define PHP_MODULE_INFO_D ZEND_MODULE_INFO_D
  311. /* Compatibility macros */
  312. #define PHP_MINIT ZEND_MODULE_STARTUP_N
  313. #define PHP_MSHUTDOWN ZEND_MODULE_SHUTDOWN_N
  314. #define PHP_RINIT ZEND_MODULE_ACTIVATE_N
  315. #define PHP_RSHUTDOWN ZEND_MODULE_DEACTIVATE_N
  316. #define PHP_MINFO ZEND_MODULE_INFO_N
  317. #define PHP_GINIT ZEND_GINIT
  318. #define PHP_GSHUTDOWN ZEND_GSHUTDOWN
  319. #define PHP_MINIT_FUNCTION ZEND_MODULE_STARTUP_D
  320. #define PHP_MSHUTDOWN_FUNCTION ZEND_MODULE_SHUTDOWN_D
  321. #define PHP_RINIT_FUNCTION ZEND_MODULE_ACTIVATE_D
  322. #define PHP_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D
  323. #define PHP_MINFO_FUNCTION ZEND_MODULE_INFO_D
  324. #define PHP_GINIT_FUNCTION ZEND_GINIT_FUNCTION
  325. #define PHP_GSHUTDOWN_FUNCTION ZEND_GSHUTDOWN_FUNCTION
  326. #define PHP_MODULE_GLOBALS ZEND_MODULE_GLOBALS
  327. /* Output support */
  328. #include "main/php_output.h"
  329. #include "php_streams.h"
  330. #include "php_memory_streams.h"
  331. #include "fopen_wrappers.h"
  332. /* Virtual current working directory support */
  333. #include "tsrm_virtual_cwd.h"
  334. #include "zend_constants.h"
  335. /* connection status states */
  336. #define PHP_CONNECTION_NORMAL 0
  337. #define PHP_CONNECTION_ABORTED 1
  338. #define PHP_CONNECTION_TIMEOUT 2
  339. #include "php_reentrancy.h"
  340. /* Finding offsets of elements within structures.
  341. * Taken from the Apache code, which in turn, was taken from X code...
  342. */
  343. #ifndef XtOffset
  344. #if defined(CRAY) || (defined(__arm) && !(defined(LINUX) || defined(__riscos__)))
  345. #ifdef __STDC__
  346. #define XtOffset(p_type, field) _Offsetof(p_type, field)
  347. #else
  348. #ifdef CRAY2
  349. #define XtOffset(p_type, field) \
  350. (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
  351. #else /* !CRAY2 */
  352. #define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
  353. #endif /* !CRAY2 */
  354. #endif /* __STDC__ */
  355. #else /* ! (CRAY || __arm) */
  356. #define XtOffset(p_type, field) \
  357. ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
  358. #endif /* !CRAY */
  359. #endif /* ! XtOffset */
  360. #ifndef XtOffsetOf
  361. #ifdef offsetof
  362. #define XtOffsetOf(s_type, field) offsetof(s_type, field)
  363. #else
  364. #define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
  365. #endif
  366. #endif /* !XtOffsetOf */
  367. #endif
  368. /*
  369. * Local variables:
  370. * tab-width: 4
  371. * c-basic-offset: 4
  372. * End:
  373. * vim600: sw=4 ts=4 fdm=marker
  374. * vim<600: sw=4 ts=4
  375. */