1 /* 2 +----------------------------------------------------------------------+ 3 | Swoole | 4 +----------------------------------------------------------------------+ 5 | This source file is subject to version 2.0 of the Apache license, | 6 | that is bundled with this package in the file LICENSE, and is | 7 | available through the world-wide-web at the following url: | 8 | http://www.apache.org/licenses/LICENSE-2.0.html | 9 | If you did not receive a copy of the Apache2.0 license and are unable| 10 | to obtain it through the world-wide-web, please send a note to | 11 | license@swoole.com so we can mail you a copy immediately. | 12 +----------------------------------------------------------------------+ 13 | Author: Tianfeng Han <mikan.tenny@gmail.com> | 14 +----------------------------------------------------------------------+ 15 */ 16 17 #ifndef SW_C_API_H_ 18 #define SW_C_API_H_ 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #include <stdint.h> 25 #include <stdbool.h> 26 27 #include "swoole_config.h" 28 29 enum swGlobalHookType { 30 SW_GLOBAL_HOOK_BEFORE_SERVER_START, 31 SW_GLOBAL_HOOK_BEFORE_CLIENT_START, 32 SW_GLOBAL_HOOK_BEFORE_WORKER_START, 33 SW_GLOBAL_HOOK_ON_CORO_START, 34 SW_GLOBAL_HOOK_ON_CORO_STOP, 35 SW_GLOBAL_HOOK_ON_REACTOR_CREATE, 36 SW_GLOBAL_HOOK_BEFORE_SERVER_SHUTDOWN, 37 SW_GLOBAL_HOOK_AFTER_SERVER_SHUTDOWN, 38 SW_GLOBAL_HOOK_BEFORE_WORKER_STOP, 39 SW_GLOBAL_HOOK_ON_REACTOR_DESTROY, 40 SW_GLOBAL_HOOK_BEFORE_SERVER_CREATE, 41 SW_GLOBAL_HOOK_AFTER_SERVER_CREATE, 42 SW_GLOBAL_HOOK_USER = 24, 43 SW_GLOBAL_HOOK_END = SW_MAX_HOOK_TYPE - 1, 44 }; 45 46 typedef void (*swHookFunc)(void *data); 47 48 int swoole_add_function(const char *name, void *func); 49 void *swoole_get_function(const char *name, uint32_t length); 50 51 int swoole_add_hook(enum swGlobalHookType type, swHookFunc cb, int push_back); 52 void swoole_call_hook(enum swGlobalHookType type, void *arg); 53 bool swoole_isset_hook(enum swGlobalHookType type); 54 55 const char *swoole_version(void); 56 int swoole_version_id(void); 57 int swoole_api_version_id(void); 58 59 #ifdef __cplusplus 60 } /* end extern "C" */ 61 #endif 62 #endif 63