1 /*
2   +----------------------------------------------------------------------+
3   | Yar - Light, concurrent RPC framework                                |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 2012-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   | Author:  Xinchen Hui   <laruence@php.net>                            |
16   |          Zhenyu  Zhang <zhangzhenyu@php.net>                         |
17   +----------------------------------------------------------------------+
18 */
19 
20 /* $Id$ */
21 
22 #ifndef PHP_YAR_H
23 #define PHP_YAR_H
24 
25 extern zend_module_entry yar_module_entry;
26 #define phpext_yar_ptr &yar_module_entry
27 
28 #ifdef PHP_WIN32
29 #	define PHP_YAR_API __declspec(dllexport)
30 #elif defined(__GNUC__) && __GNUC__ >= 4
31 #	define PHP_YAR_API __attribute__ ((visibility("default")))
32 #else
33 #	define PHP_YAR_API
34 #endif
35 
36 #ifdef ZTS
37 #include "TSRM.h"
38 #endif
39 
40 #define PHP_YAR_VERSION  "2.2.0"
41 
42 PHP_MINIT_FUNCTION(yar);
43 PHP_MSHUTDOWN_FUNCTION(yar);
44 PHP_RINIT_FUNCTION(yar);
45 PHP_RSHUTDOWN_FUNCTION(yar);
46 PHP_MINFO_FUNCTION(yar);
47 
48 ZEND_BEGIN_MODULE_GLOBALS(yar)
49 	char *default_packager;
50 	char *default_transport;
51     const struct _yar_packager *packager;
52     const struct _yar_transport *transport;
53     struct _yar_request *request;
54     struct _yar_response *response;
55 	char *content_type;
56 	zend_bool debug;
57 	zend_bool expose_info;
58 	zend_bool allow_persistent;
59 	zend_ulong timeout;
60 	zend_ulong connect_timeout;
61 ZEND_END_MODULE_GLOBALS(yar)
62 
63 #ifdef ZTS
64 #define YAR_G(v) TSRMG(yar_globals_id, zend_yar_globals *, v)
65 #else
66 #define YAR_G(v) (yar_globals.v)
67 #endif
68 
69 extern ZEND_DECLARE_MODULE_GLOBALS(yar);
70 
71 #define YAR_STARTUP_FUNCTION(module)   	ZEND_MINIT_FUNCTION(yar_##module)
72 #define YAR_STARTUP(module)	 		  	ZEND_MODULE_STARTUP_N(yar_##module)(INIT_FUNC_ARGS_PASSTHRU)
73 #define YAR_SHUTDOWN_FUNCTION(module)   	ZEND_MSHUTDOWN_FUNCTION(yar_##module)
74 #define YAR_SHUTDOWN(module)	 		  	ZEND_MODULE_SHUTDOWN_N(yar_##module)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
75 #define YAR_ACTIVATE_FUNCTION(module)   	ZEND_MODULE_ACTIVATE_D(yar_##module)
76 #define YAR_ACTIVATE(module)	 		  	ZEND_MODULE_ACTIVATE_N(yar_##module)(INIT_FUNC_ARGS_PASSTHRU)
77 #define YAR_DEACTIVATE_FUNCTION(module)  ZEND_MODULE_DEACTIVATE_D(yar_##module)
78 #define YAR_DEACTIVATE(module)           ZEND_MODULE_DEACTIVATE_N(yar_##module)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
79 
80 #if PHP_VERSION_ID < 70200
81 extern zend_string *php_yar_char_str[26];
82 #define ZSTR_CHAR(i) php_yar_char_str[i - 'a']
83 #endif
84 
85 #define YAR_OPT_PACKAGER 			(1<<0)
86 #define YAR_OPT_PERSISTENT 			(1<<1)
87 #define YAR_OPT_TIMEOUT  			(1<<2)
88 #define YAR_OPT_CONNECT_TIMEOUT 	(1<<3)
89 #define YAR_OPT_HEADER				(1<<4)
90 #define YAR_OPT_RESOLVE 			(1<<5)
91 
92 #define DEBUG_S(fmt, ...) \
93 	do { \
94 		if (UNEXPECTED(YAR_G(debug))) { \
95 			 php_yar_debug(1, fmt, ##__VA_ARGS__); \
96 		} \
97 	} while (0)
98 
99 #define DEBUG_C(fmt, ...) \
100 	do { \
101 		if (UNEXPECTED(YAR_G(debug))) { \
102 			 php_yar_debug(0, fmt, ##__VA_ARGS__); \
103 		} \
104 	} while (0)
105 
106 void php_yar_debug(int server_side, const char *format, ...);
107 
108 #endif	/* PHP_YAR_H */
109 
110 /*
111  * Local variables:
112  * tab-width: 4
113  * c-basic-offset: 4
114  * End:
115  * vim600: noet sw=4 ts=4 fdm=marker
116  * vim<600: noet sw=4 ts=4
117  */
118