2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2014, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
13 #ifndef PHP_HTTP_CLIENT_CURL_H
14 #define PHP_HTTP_CLIENT_CURL_H
16 #if PHP_HTTP_HAVE_CURL
18 typedef struct php_http_client_curl_handle
{
21 } php_http_client_curl_handle_t
;
23 typedef struct php_http_client_curl_ops
{
25 void (*dtor
)(void **ctx_ptr
);
26 ZEND_RESULT_CODE (*once
)(void *ctx
);
27 ZEND_RESULT_CODE (*wait
)(void *ctx
, struct timeval
*custom_timeout
);
28 ZEND_RESULT_CODE (*exec
)(void *ctx
);
29 } php_http_client_curl_ops_t
;
31 typedef struct php_http_client_curl
{
32 php_http_client_curl_handle_t
*handle
;
34 int unfinished
; /* int because of curl_multi_perform() */
37 php_http_client_curl_ops_t
*ev_ops
;
38 } php_http_client_curl_t
;
40 static inline void php_http_client_curl_get_timeout(php_http_client_curl_t
*curl
, long max_tout
, struct timeval
*timeout
)
42 if ((CURLM_OK
== curl_multi_timeout(curl
->handle
->multi
, &max_tout
)) && (max_tout
> 0)) {
43 timeout
->tv_sec
= max_tout
/ 1000;
44 timeout
->tv_usec
= (max_tout
% 1000) * 1000;
47 timeout
->tv_usec
= 1000;
51 PHP_HTTP_API
void php_http_client_curl_responsehandler(php_http_client_t
*client
);
52 PHP_HTTP_API
void php_http_client_curl_loop(php_http_client_t
*client
, curl_socket_t s
, int curl_action
);
54 PHP_MINIT_FUNCTION(http_client_curl
);
55 PHP_MSHUTDOWN_FUNCTION(http_client_curl
);
56 #endif /* PHP_HTTP_HAVE_CURL */
58 #endif /* PHP_HTTP_CLIENT_CURL_H */
65 * vim600: noet sw=4 ts=4 fdm=marker
66 * vim<600: noet sw=4 ts=4