+static int apply_available_options(zval *pDest, int num_args, va_list args, zend_hash_key *hash_key)
+{
+ php_http_option_t *opt = Z_PTR_P(pDest);
+ HashTable *ht;
+ zval entry;
+ int c;
+
+ ht = va_arg(args, HashTable*);
+
+ if ((c = zend_hash_num_elements(&opt->suboptions.options))) {
+ array_init_size(&entry, c);
+ zend_hash_apply_with_arguments(&opt->suboptions.options, apply_available_options, 1, Z_ARRVAL(entry));
+ } else {
+ /* catch deliberate NULL options */
+ if (Z_TYPE(opt->defval) == IS_STRING && !Z_STRVAL(opt->defval)) {
+ ZVAL_NULL(&entry);
+ } else {
+ ZVAL_ZVAL(&entry, &opt->defval, 1, 0);
+ }
+ }
+
+ if (hash_key->key) {
+ zend_hash_update(ht, hash_key->key, &entry);
+ } else {
+ zend_hash_index_update(ht, hash_key->h, &entry);
+ }
+
+ return ZEND_HASH_APPLY_KEEP;
+}
+
+static ZEND_RESULT_CODE php_http_client_curl_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void **res)