-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp_event.h
More file actions
213 lines (180 loc) · 3.87 KB
/
php_event.h
File metadata and controls
213 lines (180 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
* Zarium libevent îáåðòêà
*/
#ifndef PHP_EVENT_H
#define PHP_EVENT_H
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
extern zend_module_entry event_module_entry;
#define phpext_event_ptr &event_module_entry
#ifdef PHP_WIN32
#define PHP_EVENT_API __declspec(dllexport)
#else
#define PHP_EVENT_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
/* refcount ìàêðîñû */
#ifndef Z_ADDREF_P
#define Z_ADDREF_P(pz) (pz)->refcount++
#endif
#ifndef Z_DELREF_P
#define Z_DELREF_P(pz) (pz)->refcount--
#endif
#ifndef Z_SET_REFCOUNT_P
#define Z_SET_REFCOUNT_P(pz, rc) (pz)->refcount = rc
#endif
PHP_MINIT_FUNCTION(event);
PHP_MSHUTDOWN_FUNCTION(event);
PHP_RINIT_FUNCTION(event);
PHP_RSHUTDOWN_FUNCTION(event);
PHP_MINFO_FUNCTION(event);
PHP_FUNCTION(console_write);
/*
* Ñòàíäàðòíûå libevent ôóíêöèè
*/
PHP_FUNCTION(event_init);
PHP_FUNCTION(event_reinit);
PHP_FUNCTION(event_new);
PHP_FUNCTION(event_free);
PHP_FUNCTION(event_set);
PHP_FUNCTION(event_add);
PHP_FUNCTION(event_del);
PHP_FUNCTION(event_dispatch);
PHP_FUNCTION(event_loopbreak);
/*
* Ôóíêöèè HTTP Client/Server
*/
PHP_FUNCTION(evhttp_start);
PHP_FUNCTION(evhttp_set_gencb);
PHP_FUNCTION(evhttp_connection_new);
PHP_FUNCTION(evhttp_connection_set_closecb);
PHP_FUNCTION(evhttp_request_new);
PHP_FUNCTION(evhttp_request_free);
PHP_FUNCTION(evhttp_make_request);
/*
* Ôóíêöèè çàïðîñà HTTP
*/
PHP_FUNCTION(evhttp_request_get_uri);
PHP_FUNCTION(evhttp_request_method);
PHP_FUNCTION(evhttp_request_body);
PHP_FUNCTION(evhttp_request_input_buffer);
PHP_FUNCTION(evhttp_request_headers);
PHP_FUNCTION(evhttp_request_find_header);
PHP_FUNCTION(evhttp_request_add_header);
PHP_FUNCTION(evhttp_request_status);
PHP_FUNCTION(evhttp_request_append_body);
/*
* Ôóíêöèè áóôåðîâ
*/
PHP_FUNCTION(evbuffer_new);
PHP_FUNCTION(evbuffer_free);
PHP_FUNCTION(evbuffer_add);
PHP_FUNCTION(evbuffer_readline);
/*
* HTTP Ôóíêöèè îòâåòà
*/
PHP_FUNCTION(evhttp_response_set);
PHP_FUNCTION(evhttp_response_add_header);
/*
* Ñîáûòèÿ äëÿ bufferevent
*/
PHP_FUNCTION(bufferevent_new);
PHP_FUNCTION(bufferevent_enable);
PHP_FUNCTION(bufferevent_disable);
PHP_FUNCTION(bufferevent_read);
PHP_FUNCTION(bufferevent_write);
PHP_FUNCTION(ntohs);
PHP_FUNCTION(ntohl);
PHP_FUNCTION(htons);
PHP_FUNCTION(htonl);
#define PHP_EVENT_RES_NAME "EVENT"
#define PHP_BUFFEREVENT_RES_NAME "BUFFEREVENT"
#define PHP_EVHTTP_RES_NAME "EVHTTP"
#define PHP_EVHTTP_REQUEST_RES_NAME "EVHTTP Request"
#define PHP_EVHTTP_CONNECTION_RES_NAME "EVHTTP Connection"
#define PHP_EVBUFFER_RES_NAME "EVBUFFER"
#define PHP_EVHTTP_RESPONSE_RES_NAME "EVHTTP Response"
#ifdef ZTS
#define EVENT_G(v) TSRMG(event_globals_id, zend_event_globals *, v)
#else
#define EVENT_G(v) (event_globals.v)
#endif
/*
* Ñòðóêòóðà äëÿ PHP Event
*/
typedef struct _php_event
{
zval *stream;
zval *cb;
zval *flags;
zval *event;
#ifdef ZTS
TSRMLS_D;
#endif
} php_event;
/*
* Ñòðóêòóðà bufferevent äëÿ PHP Event
*/
typedef struct _php_bufferevent
{
zval *res_bufferevent;
zval *stream;
zval *r_cb;
zval *w_cb;
zval *e_cb;
#ifdef ZTS
TSRMLS_D;
#endif
} php_bufferevent;
/*
* Ñòðóêòóðà httpevent äëÿ PHP Event
*/
typedef struct _php_httpevent
{
zval *res_httpevent;
zval *r_cb;
#ifdef ZTS
TSRMLS_D;
#endif
} php_httpevent;
/*
* Ñòóðêóòóðà äëÿ PHP Event (evhttp_connection)
* íåîáõîäèìóþ äëÿ çàêðûòèÿ ñîåäèíåíèÿ HTTP ïî onClose
*/
typedef struct _php_httpcon
{
zval *res_httpcon;
zval *c_cb;
#ifdef ZTS
TSRMLS_D;
#endif
} php_httpcon;
/*
* Êàñòîìíûå ñòðóêòóðû äëÿ HTTP êîäà îòâåòà è ñîîáùåíèÿ àññîöèèðîâàííîûõ
* ñ îïðåäåëåííûì áóôåðîì.
* Libevent èñïîëüçóåò evhttp_request ñòðóêòóðó äëÿ çàïðîñîâ è îòâåòîâ
*/
typedef struct _evhttp_response
{
int res_code;
char* res_message;
char* res_body;
int res_body_len;
#ifdef ZTS
TSRMLS_D;
#endif
} evhttp_response;
typedef struct _evhttp_callback_arg
{
zval *arg;
#ifdef ZTS
TSRMLS_D;
#endif
} evhttp_callback_arg;
#endif