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_LIBCURL
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
)
49 /* always returns CURLM_OK, check max_tout instead */
50 curl_multi_timeout(curl
->handle
->multi
, &max_tout
);
60 } else if (max_tout
> 1000) {
65 timeout
->tv_sec
= max_tout
/ 1000;
66 timeout
->tv_usec
= (max_tout
% 1000) * 1000;
69 PHP_HTTP_API
void php_http_client_curl_responsehandler(php_http_client_t
*client
);
70 PHP_HTTP_API
void php_http_client_curl_loop(php_http_client_t
*client
, curl_socket_t s
, int curl_action
);
71 PHP_HTTP_API php_http_client_ops_t
*php_http_client_curl_get_ops(void);
73 PHP_MINIT_FUNCTION(http_client_curl
);
74 PHP_MSHUTDOWN_FUNCTION(http_client_curl
);
76 #endif /* PHP_HTTP_HAVE_LIBCURL */
78 #endif /* PHP_HTTP_CLIENT_CURL_H */
85 * vim600: noet sw=4 ts=4 fdm=marker
86 * vim<600: noet sw=4 ts=4