zend_extensions.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend Engine |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.00 of the Zend 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.zend.com/license/2_00.txt. |
  11. | If you did not receive a copy of the Zend license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@zend.com so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Andi Gutmans <andi@php.net> |
  16. | Zeev Suraski <zeev@php.net> |
  17. +----------------------------------------------------------------------+
  18. */
  19. #ifndef ZEND_EXTENSIONS_H
  20. #define ZEND_EXTENSIONS_H
  21. #include "zend_compile.h"
  22. #include "zend_build.h"
  23. /*
  24. The constants below are derived from ext/opcache/ZendAccelerator.h
  25. You can use the following macro to check the extension API version for compatibilities:
  26. #define ZEND_EXTENSION_API_NO_5_0_X 220040412
  27. #define ZEND_EXTENSION_API_NO_5_1_X 220051025
  28. #define ZEND_EXTENSION_API_NO_5_2_X 220060519
  29. #define ZEND_EXTENSION_API_NO_5_3_X 220090626
  30. #define ZEND_EXTENSION_API_NO_5_4_X 220100525
  31. #define ZEND_EXTENSION_API_NO_5_5_X 220121212
  32. #define ZEND_EXTENSION_API_NO_5_6_X 220131226
  33. #define ZEND_EXTENSION_API_NO_7_0_X 320151012
  34. #if ZEND_EXTENSION_API_NO < ZEND_EXTENSION_API_NO_5_5_X
  35. // do something for php versions lower than 5.5.x
  36. #endif
  37. */
  38. /* The first number is the engine version and the rest is the date (YYYYMMDD).
  39. * This way engine 2/3 API no. is always greater than engine 1 API no.. */
  40. #define ZEND_EXTENSION_API_NO 420210902
  41. typedef struct _zend_extension_version_info {
  42. int zend_extension_api_no;
  43. const char *build_id;
  44. } zend_extension_version_info;
  45. #define ZEND_EXTENSION_BUILD_ID "API" ZEND_TOSTR(ZEND_EXTENSION_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA
  46. typedef struct _zend_extension zend_extension;
  47. /* Typedef's for zend_extension function pointers */
  48. typedef int (*startup_func_t)(zend_extension *extension);
  49. typedef void (*shutdown_func_t)(zend_extension *extension);
  50. typedef void (*activate_func_t)(void);
  51. typedef void (*deactivate_func_t)(void);
  52. typedef void (*message_handler_func_t)(int message, void *arg);
  53. typedef void (*op_array_handler_func_t)(zend_op_array *op_array);
  54. typedef void (*statement_handler_func_t)(zend_execute_data *frame);
  55. typedef void (*fcall_begin_handler_func_t)(zend_execute_data *frame);
  56. typedef void (*fcall_end_handler_func_t)(zend_execute_data *frame);
  57. typedef void (*op_array_ctor_func_t)(zend_op_array *op_array);
  58. typedef void (*op_array_dtor_func_t)(zend_op_array *op_array);
  59. typedef size_t (*op_array_persist_calc_func_t)(zend_op_array *op_array);
  60. typedef size_t (*op_array_persist_func_t)(zend_op_array *op_array, void *mem);
  61. struct _zend_extension {
  62. const char *name;
  63. const char *version;
  64. const char *author;
  65. const char *URL;
  66. const char *copyright;
  67. startup_func_t startup;
  68. shutdown_func_t shutdown;
  69. activate_func_t activate;
  70. deactivate_func_t deactivate;
  71. message_handler_func_t message_handler;
  72. op_array_handler_func_t op_array_handler;
  73. statement_handler_func_t statement_handler;
  74. fcall_begin_handler_func_t fcall_begin_handler;
  75. fcall_end_handler_func_t fcall_end_handler;
  76. op_array_ctor_func_t op_array_ctor;
  77. op_array_dtor_func_t op_array_dtor;
  78. int (*api_no_check)(int api_no);
  79. int (*build_id_check)(const char* build_id);
  80. op_array_persist_calc_func_t op_array_persist_calc;
  81. op_array_persist_func_t op_array_persist;
  82. void *reserved5;
  83. void *reserved6;
  84. void *reserved7;
  85. void *reserved8;
  86. DL_HANDLE handle;
  87. int resource_number;
  88. };
  89. BEGIN_EXTERN_C()
  90. extern ZEND_API int zend_op_array_extension_handles;
  91. ZEND_API int zend_get_resource_handle(const char *module_name);
  92. ZEND_API int zend_get_op_array_extension_handle(const char *module_name);
  93. ZEND_API int zend_get_op_array_extension_handles(const char *module_name, int handles);
  94. ZEND_API void zend_extension_dispatch_message(int message, void *arg);
  95. END_EXTERN_C()
  96. #define ZEND_EXTMSG_NEW_EXTENSION 1
  97. #define ZEND_EXTENSION() \
  98. ZEND_EXT_API zend_extension_version_info extension_version_info = { ZEND_EXTENSION_API_NO, ZEND_EXTENSION_BUILD_ID }
  99. #define STANDARD_ZEND_EXTENSION_PROPERTIES NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
  100. #define COMPAT_ZEND_EXTENSION_PROPERTIES NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
  101. #define BUILD_COMPAT_ZEND_EXTENSION_PROPERTIES NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
  102. ZEND_API extern zend_llist zend_extensions;
  103. ZEND_API extern uint32_t zend_extension_flags;
  104. #define ZEND_EXTENSIONS_HAVE_OP_ARRAY_CTOR (1<<0)
  105. #define ZEND_EXTENSIONS_HAVE_OP_ARRAY_DTOR (1<<1)
  106. #define ZEND_EXTENSIONS_HAVE_OP_ARRAY_HANDLER (1<<2)
  107. #define ZEND_EXTENSIONS_HAVE_OP_ARRAY_PERSIST_CALC (1<<3)
  108. #define ZEND_EXTENSIONS_HAVE_OP_ARRAY_PERSIST (1<<4)
  109. void zend_extension_dtor(zend_extension *extension);
  110. ZEND_API void zend_append_version_info(const zend_extension *extension);
  111. void zend_startup_extensions_mechanism(void);
  112. void zend_startup_extensions(void);
  113. void zend_shutdown_extensions(void);
  114. BEGIN_EXTERN_C()
  115. ZEND_API zend_result zend_load_extension(const char *path);
  116. ZEND_API zend_result zend_load_extension_handle(DL_HANDLE handle, const char *path);
  117. ZEND_API void zend_register_extension(zend_extension *new_extension, DL_HANDLE handle);
  118. ZEND_API zend_extension *zend_get_extension(const char *extension_name);
  119. ZEND_API size_t zend_extensions_op_array_persist_calc(zend_op_array *op_array);
  120. ZEND_API size_t zend_extensions_op_array_persist(zend_op_array *op_array, void *mem);
  121. END_EXTERN_C()
  122. #endif /* ZEND_EXTENSIONS_H */