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 struct php_http_client_curl_globals
{
19 php_http_client_driver_t driver
;
22 typedef struct php_http_client_curl_handle
{
25 } php_http_client_curl_handle_t
;
27 typedef struct php_http_client_curl_ops
{
29 void (*dtor
)(void **ctx_ptr
);
30 ZEND_RESULT_CODE (*once
)(void *ctx
);
31 ZEND_RESULT_CODE (*wait
)(void *ctx
, struct timeval
*custom_timeout
);
32 ZEND_RESULT_CODE (*exec
)(void *ctx
);
33 } php_http_client_curl_ops_t
;
35 typedef struct php_http_client_curl
{
36 php_http_client_curl_handle_t
*handle
;
38 int unfinished
; /* int because of curl_multi_perform() */
41 php_http_client_curl_ops_t
*ev_ops
;
42 } php_http_client_curl_t
;
44 static inline void php_http_client_curl_get_timeout(php_http_client_curl_t
*curl
, long max_tout
, struct timeval
*timeout
)
46 if ((CURLM_OK
== curl_multi_timeout(curl
->handle
->multi
, &max_tout
)) && (max_tout
> 0)) {
47 timeout
->tv_sec
= max_tout
/ 1000;
48 timeout
->tv_usec
= (max_tout
% 1000) * 1000;
51 timeout
->tv_usec
= 1000;
55 PHP_HTTP_API
void php_http_client_curl_responsehandler(php_http_client_t
*client
);
56 PHP_HTTP_API
void php_http_client_curl_loop(php_http_client_t
*client
, curl_socket_t s
, int curl_action
);
57 PHP_HTTP_API php_http_client_ops_t
*php_http_client_curl_get_ops(void);
59 PHP_MINIT_FUNCTION(http_client_curl
);
60 PHP_MSHUTDOWN_FUNCTION(http_client_curl
);
62 #endif /* PHP_HTTP_HAVE_CURL */
64 #endif /* PHP_HTTP_CLIENT_CURL_H */
71 * vim600: noet sw=4 ts=4 fdm=marker
72 * vim<600: noet sw=4 ts=4