+/* {{{ static inline char *http_curl_getinfoname(CURLINFO) */
+static inline char *_http_curl_getinfoname(CURLINFO i TSRMLS_DC)
+{
+#define CASE(I) case CURLINFO_ ##I : return pretty_key(estrdup( #I ), strlen(#I), 0, 0)
+ switch (i)
+ {
+ /* CURLINFO_EFFECTIVE_URL = CURLINFO_STRING +1, */
+ CASE(EFFECTIVE_URL);
+ /* CURLINFO_RESPONSE_CODE = CURLINFO_LONG +2, */
+ CASE(RESPONSE_CODE);
+ /* CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE +3, */
+ CASE(TOTAL_TIME);
+ /* CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE +4, */
+ CASE(NAMELOOKUP_TIME);
+ /* CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE +5, */
+ CASE(CONNECT_TIME);
+ /* CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE +6, */
+ CASE(PRETRANSFER_TIME);
+ /* CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE +7, */
+ CASE(SIZE_UPLOAD);
+ /* CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE +8, */
+ CASE(SIZE_DOWNLOAD);
+ /* CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE +9, */
+ CASE(SPEED_DOWNLOAD);
+ /* CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE +10, */
+ CASE(SPEED_UPLOAD);
+ /* CURLINFO_HEADER_SIZE = CURLINFO_LONG +11, */
+ CASE(HEADER_SIZE);
+ /* CURLINFO_REQUEST_SIZE = CURLINFO_LONG +12, */
+ CASE(REQUEST_SIZE);
+ /* CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG +13, */
+ CASE(SSL_VERIFYRESULT);
+ /* CURLINFO_FILETIME = CURLINFO_LONG +14, */
+ CASE(FILETIME);
+ /* CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE +15, */
+ CASE(CONTENT_LENGTH_DOWNLOAD);
+ /* CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE +16, */
+ CASE(CONTENT_LENGTH_UPLOAD);
+ /* CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE +17, */
+ CASE(STARTTRANSFER_TIME);
+ /* CURLINFO_CONTENT_TYPE = CURLINFO_STRING +18, */
+ CASE(CONTENT_TYPE);
+ /* CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE +19, */
+ CASE(REDIRECT_TIME);
+ /* CURLINFO_REDIRECT_COUNT = CURLINFO_LONG +20, */
+ CASE(REDIRECT_COUNT);
+ /* CURLINFO_PRIVATE = CURLINFO_STRING +21, */
+ CASE(PRIVATE);
+ /* CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG +22, */
+ CASE(HTTP_CONNECTCODE);
+ /* CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG +23, */
+ CASE(HTTPAUTH_AVAIL);
+ /* CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG +24, */
+ CASE(PROXYAUTH_AVAIL);
+ }
+#undef CASE
+ return NULL;
+}
+/* }}} */
+
+/* {{{ static inline void http_curl_getinfo_ex(CURL, CURLINFO, zval *) */
+static inline void _http_curl_getinfo_ex(CURL *ch, CURLINFO i, zval *array TSRMLS_DC)
+{
+ char *key;
+ if (key = http_curl_getinfoname(i)) {
+ switch (i & ~CURLINFO_MASK)
+ {
+ case CURLINFO_STRING:
+ {
+ char *c;
+ if (CURLE_OK == curl_easy_getinfo(ch, i, &c)) {
+ add_assoc_string(array, key, c ? c : "", 1);
+ }
+ }
+ break;
+
+ case CURLINFO_DOUBLE:
+ {
+ double d;
+ if (CURLE_OK == curl_easy_getinfo(ch, i, &d)) {
+ add_assoc_double(array, key, d);
+ }
+ }
+ break;
+
+ case CURLINFO_LONG:
+ {
+ long l;
+ if (CURLE_OK == curl_easy_getinfo(ch, i, &l)) {
+ add_assoc_long(array, key, l);
+ }
+ }
+ break;
+ }
+ }
+}
+/* }}} */
+
+/* {{{ static inline http_curl_getinfo(CURL, HashTable *) */
+static inline void _http_curl_getinfo(CURL *ch, HashTable *info TSRMLS_DC)
+{
+ zval array;
+ Z_ARRVAL(array) = info;
+
+#define INFO(I) http_curl_getinfo_ex(ch, CURLINFO_ ##I , &array)
+ /* CURLINFO_EFFECTIVE_URL = CURLINFO_STRING +1, */
+ INFO(EFFECTIVE_URL);
+ /* CURLINFO_RESPONSE_CODE = CURLINFO_LONG +2, */
+ INFO(RESPONSE_CODE);
+ /* CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE +3, */
+ INFO(TOTAL_TIME);
+ /* CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE +4, */
+ INFO(NAMELOOKUP_TIME);
+ /* CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE +5, */
+ INFO(CONNECT_TIME);
+ /* CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE +6, */
+ INFO(PRETRANSFER_TIME);
+ /* CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE +7, */
+ INFO(SIZE_UPLOAD);
+ /* CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE +8, */
+ INFO(SIZE_DOWNLOAD);
+ /* CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE +9, */
+ INFO(SPEED_DOWNLOAD);
+ /* CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE +10, */
+ INFO(SPEED_UPLOAD);
+ /* CURLINFO_HEADER_SIZE = CURLINFO_LONG +11, */
+ INFO(HEADER_SIZE);
+ /* CURLINFO_REQUEST_SIZE = CURLINFO_LONG +12, */
+ INFO(REQUEST_SIZE);
+ /* CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG +13, */
+ INFO(SSL_VERIFYRESULT);
+ /* CURLINFO_FILETIME = CURLINFO_LONG +14, */
+ INFO(FILETIME);
+ /* CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE +15, */
+ INFO(CONTENT_LENGTH_DOWNLOAD);
+ /* CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE +16, */
+ INFO(CONTENT_LENGTH_UPLOAD);
+ /* CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE +17, */
+ INFO(STARTTRANSFER_TIME);
+ /* CURLINFO_CONTENT_TYPE = CURLINFO_STRING +18, */
+ INFO(CONTENT_TYPE);
+ /* CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE +19, */
+ INFO(REDIRECT_TIME);
+ /* CURLINFO_REDIRECT_COUNT = CURLINFO_LONG +20, */
+ INFO(REDIRECT_COUNT);
+ /* CURLINFO_PRIVATE = CURLINFO_STRING +21, */
+ INFO(PRIVATE);
+ /* CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG +22, */
+ INFO(HTTP_CONNECTCODE);
+ /* CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG +23, */
+ INFO(HTTPAUTH_AVAIL);
+ /* CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG +24, */
+ INFO(PROXYAUTH_AVAIL);
+#undef INFO
+}
+/* }}} */
+