- reorder includes, always include php.h first
[m6w6/ext-http] / http_requestpool_object.c
1 /*
2 +----------------------------------------------------------------------+
3 | PECL :: http |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.0 of the PHP license, that |
6 | is bundled with this package in the file LICENSE, and is available |
7 | through the world-wide-web at http://www.php.net/license/3_0.txt. |
8 | If you did not receive a copy of the PHP license and are unable to |
9 | obtain it through the world-wide-web, please send a note to |
10 | license@php.net so we can mail you a copy immediately. |
11 +----------------------------------------------------------------------+
12 | Copyright (c) 2004-2005 Michael Wallner <mike@php.net> |
13 +----------------------------------------------------------------------+
14 */
15
16 /* $Id$ */
17
18
19 #ifdef HAVE_CONFIG_H
20 # include "config.h"
21 #endif
22 #include "php.h"
23
24 #if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
25
26 #include "php_http_std_defs.h"
27 #include "php_http_requestpool_object.h"
28 #include "php_http_request_pool_api.h"
29
30 #ifdef PHP_WIN32
31 # include <winsock2.h>
32 #endif
33 #include <curl/curl.h>
34
35 HTTP_DECLARE_ARG_PASS_INFO();
36
37 #define http_requestpool_object_declare_default_properties() _http_requestpool_object_declare_default_properties(TSRMLS_C)
38 static inline void _http_requestpool_object_declare_default_properties(TSRMLS_D);
39
40 zend_class_entry *http_requestpool_object_ce;
41 zend_function_entry http_requestpool_object_fe[] = {
42 PHP_ME(HttpRequestPool, __construct, http_arg_pass_ref_all, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
43 PHP_ME(HttpRequestPool, __destruct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
44 PHP_ME(HttpRequestPool, attach, NULL, ZEND_ACC_PUBLIC)
45 PHP_ME(HttpRequestPool, detach, NULL, ZEND_ACC_PUBLIC)
46 PHP_ME(HttpRequestPool, send, NULL, ZEND_ACC_PUBLIC)
47 PHP_ME(HttpRequestPool, reset, NULL, ZEND_ACC_PUBLIC)
48
49 PHP_ME(HttpRequestPool, socketSend, NULL, ZEND_ACC_PROTECTED)
50 PHP_ME(HttpRequestPool, socketSelect, NULL, ZEND_ACC_PROTECTED)
51 PHP_ME(HttpRequestPool, socketRead, NULL, ZEND_ACC_PROTECTED)
52
53 {NULL, NULL, NULL}
54 };
55 static zend_object_handlers http_requestpool_object_handlers;
56
57 void _http_requestpool_object_init(INIT_FUNC_ARGS)
58 {
59 HTTP_REGISTER_CLASS_EX(HttpRequestPool, http_requestpool_object, NULL, 0);
60 }
61
62 zend_object_value _http_requestpool_object_new(zend_class_entry *ce TSRMLS_DC)
63 {
64 zend_object_value ov;
65 http_requestpool_object *o;
66
67 o = ecalloc(1, sizeof(http_requestpool_object));
68 o->zo.ce = ce;
69
70 http_request_pool_init(&o->pool);
71
72 ALLOC_HASHTABLE(OBJ_PROP(o));
73 zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0);
74 zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
75
76 ov.handle = zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, http_requestpool_object_free, NULL TSRMLS_CC);
77 ov.handlers = &http_requestpool_object_handlers;
78
79 return ov;
80 }
81
82 static inline void _http_requestpool_object_declare_default_properties(TSRMLS_D)
83 {
84 zend_class_entry *ce = http_requestpool_object_ce;
85
86 DCL_PROP_N(PROTECTED, pool);
87 }
88
89 void _http_requestpool_object_free(zend_object *object TSRMLS_DC)
90 {
91 http_requestpool_object *o = (http_requestpool_object *) object;
92
93 if (OBJ_PROP(o)) {
94 zend_hash_destroy(OBJ_PROP(o));
95 FREE_HASHTABLE(OBJ_PROP(o));
96 }
97 http_request_pool_dtor(&o->pool);
98 efree(o);
99 }
100
101 #endif /* ZEND_ENGINE_2 && HTTP_HAVE_CURL */
102
103 /*
104 * Local variables:
105 * tab-width: 4
106 * c-basic-offset: 4
107 * End:
108 * vim600: noet sw=4 ts=4 fdm=marker
109 * vim<600: noet sw=4 ts=4
110 */
111