+static int apply_available_options(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
+{
+ php_http_option_t *opt = pDest;
+ HashTable *ht;
+ zval *entry;
+ int c;
+
+ ht = va_arg(args, HashTable*);
+
+ MAKE_STD_ZVAL(entry);
+
+ if ((c = zend_hash_num_elements(&opt->suboptions.options))) {
+ array_init_size(entry, c);
+ zend_hash_apply_with_arguments(&opt->suboptions.options TSRMLS_CC, apply_available_options, 1, Z_ARRVAL_P(entry));
+ } else {
+ /* catch deliberate NULL options */
+ if (Z_TYPE(opt->defval) == IS_STRING && !Z_STRVAL(opt->defval)) {
+ ZVAL_NULL(entry);
+ } else {
+ ZVAL_COPY_VALUE(entry, &opt->defval);
+ zval_copy_ctor(entry);
+ }
+ }
+
+ if (hash_key->nKeyLength) {
+ zend_hash_quick_update(ht, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void *) &entry, sizeof(zval *), NULL);
+ } else {
+ zend_hash_index_update(ht, hash_key->h, (void *) &entry, sizeof(zval *), NULL);
+ }
+
+ return ZEND_HASH_APPLY_KEEP;
+}
+