static void overlay_same(abts_case *tc, void *data) { apr_hash_t *base = NULL; apr_hash_t *result = NULL; int count; char StrArray[MAX_DEPTH][MAX_LTH]; base = apr_hash_make(p); ABTS_PTR_NOTNULL(tc, base); apr_hash_set(base, "base1", APR_HASH_KEY_STRING, "value1"); apr_hash_set(base, "base2", APR_HASH_KEY_STRING, "value2"); apr_hash_set(base, "base3", APR_HASH_KEY_STRING, "value3"); apr_hash_set(base, "base4", APR_HASH_KEY_STRING, "value4"); apr_hash_set(base, "base5", APR_HASH_KEY_STRING, "value5"); result = apr_hash_overlay(p, base, base); count = apr_hash_count(result); ABTS_INT_EQUAL(tc, 5, count); dump_hash(p, result, StrArray); ABTS_STR_EQUAL(tc, "Key base1 (5) Value value1\n", StrArray[0]); ABTS_STR_EQUAL(tc, "Key base2 (5) Value value2\n", StrArray[1]); ABTS_STR_EQUAL(tc, "Key base3 (5) Value value3\n", StrArray[2]); ABTS_STR_EQUAL(tc, "Key base4 (5) Value value4\n", StrArray[3]); ABTS_STR_EQUAL(tc, "Key base5 (5) Value value5\n", StrArray[4]); ABTS_STR_EQUAL(tc, "#entries 5\n", StrArray[5]); }
static void overlay_empty(abts_case *tc, void *data) { apr_hash_t *base = NULL; apr_hash_t *overlay = NULL; apr_hash_t *result = NULL; int count; char StrArray[MAX_DEPTH][MAX_LTH]; base = apr_hash_make(p); overlay = apr_hash_make(p); ABTS_PTR_NOTNULL(tc, base); ABTS_PTR_NOTNULL(tc, overlay); apr_hash_set(base, "key1", APR_HASH_KEY_STRING, "value1"); apr_hash_set(base, "key2", APR_HASH_KEY_STRING, "value2"); apr_hash_set(base, "key3", APR_HASH_KEY_STRING, "value3"); apr_hash_set(base, "key4", APR_HASH_KEY_STRING, "value4"); apr_hash_set(base, "key5", APR_HASH_KEY_STRING, "value5"); result = apr_hash_overlay(p, overlay, base); count = apr_hash_count(result); ABTS_INT_EQUAL(tc, 5, count); dump_hash(p, result, StrArray); ABTS_STR_EQUAL(tc, "Key key1 (4) Value value1\n", StrArray[0]); ABTS_STR_EQUAL(tc, "Key key2 (4) Value value2\n", StrArray[1]); ABTS_STR_EQUAL(tc, "Key key3 (4) Value value3\n", StrArray[2]); ABTS_STR_EQUAL(tc, "Key key4 (4) Value value4\n", StrArray[3]); ABTS_STR_EQUAL(tc, "Key key5 (4) Value value5\n", StrArray[4]); ABTS_STR_EQUAL(tc, "#entries 5\n", StrArray[5]); }
static void *domaintree_merge_srv(apr_pool_t *p, void *old_cfg_ptr, void *new_cfg_ptr) { MDT_CNF *old_cfg = (MDT_CNF *) old_cfg_ptr, *new_cfg = (MDT_CNF *) new_cfg_ptr; MDT_CNF *DT = (MDT_CNF *) apr_palloc(p, sizeof(MDT_CNF)); DT->server = new_cfg->server; DT->enabled = IF_SET_ELSE(new_cfg->enabled, old_cfg->enabled); DT->stripwww = IF_SET_ELSE(new_cfg->stripwww, old_cfg->stripwww); DT->statroot = IF_SET_ELSE(new_cfg->statroot, old_cfg->statroot); DT->maxdepth = IF_SET_ELSE(new_cfg->maxdepth, old_cfg->maxdepth); DT->prefix = EMPTY(new_cfg->prefix) ? EMPTY(old_cfg->prefix) ? "/var/www" : old_cfg->prefix : new_cfg->prefix; DT->suffix = EMPTY(new_cfg->suffix) ? EMPTY(old_cfg->suffix) ? "public_html" : old_cfg->suffix : new_cfg->suffix; DT->ignore = apr_array_append(p, new_cfg->ignore, old_cfg->ignore); DT->forbid = apr_array_append(p, new_cfg->forbid, old_cfg->forbid); #ifdef HAVE_UNIX_SUEXEC DT->suexec = apr_array_append(p, new_cfg->suexec, old_cfg->suexec); #endif DT->aliases.recursion = IF_SET_ELSE(new_cfg->aliases.recursion, old_cfg->aliases.recursion); DT->aliases.faketable = apr_table_overlay(p, new_cfg->aliases.faketable, old_cfg->aliases.faketable); DT->dircache.clim = IF_SET_ELSE(new_cfg->dircache.clim, old_cfg->dircache.clim); DT->dircache.hmap = apr_hash_overlay(p, new_cfg->dircache.hmap, old_cfg->dircache.hmap); apr_global_mutex_create(&new_cfg->dircache.lock, __FILE__, APR_LOCK_DEFAULT, p); #if DBG fprintf(stderr, "MDT: cfg merge %p + %p = %p\n", old_cfg, new_cfg, DT); #endif return DT; }
static void overlay_same(abts_case *tc, void *data) { apr_hash_t *base = NULL; apr_hash_t *result = NULL; int count; char str[8196]; base = apr_hash_make(p); ABTS_PTR_NOTNULL(tc, base); apr_hash_set(base, "base1", APR_HASH_KEY_STRING, "value1"); apr_hash_set(base, "base2", APR_HASH_KEY_STRING, "value2"); apr_hash_set(base, "base3", APR_HASH_KEY_STRING, "value3"); apr_hash_set(base, "base4", APR_HASH_KEY_STRING, "value4"); apr_hash_set(base, "base5", APR_HASH_KEY_STRING, "value5"); result = apr_hash_overlay(p, base, base); count = apr_hash_count(result); ABTS_INT_EQUAL(tc, 5, count); dump_hash(p, result, str); /* I don't know why these are out of order, but they are. I would probably * consider this a bug, but others should comment. */ ABTS_STR_EQUAL(tc, "Key base5 (5) Value value5\n" "Key base1 (5) Value value1\n" "Key base2 (5) Value value2\n" "Key base3 (5) Value value3\n" "Key base4 (5) Value value4\n" "#entries 5\n", str); }
static void *filter_merge(apr_pool_t *pool, void *BASE, void *ADD) { mod_filter_cfg *base = BASE; mod_filter_cfg *add = ADD; mod_filter_chain *savelink = 0; mod_filter_chain *newlink; mod_filter_chain *p; mod_filter_cfg *conf = apr_palloc(pool, sizeof(mod_filter_cfg)); conf->live_filters = apr_hash_overlay(pool, add->live_filters, base->live_filters); if (base->chain && add->chain) { for (p = base->chain; p; p = p->next) { newlink = apr_pmemdup(pool, p, sizeof(mod_filter_chain)); if (newlink->fname == NULL) { conf->chain = savelink = newlink; } else if (savelink) { savelink->next = newlink; savelink = newlink; } else { conf->chain = savelink = newlink; } } for (p = add->chain; p; p = p->next) { newlink = apr_pmemdup(pool, p, sizeof(mod_filter_chain)); /** Filter out merged chain resets */ if (newlink->fname == NULL) { conf->chain = savelink = newlink; } else if (savelink) { savelink->next = newlink; savelink = newlink; } else { conf->chain = savelink = newlink; } } } else if (add->chain) { conf->chain = add->chain; } else { conf->chain = base->chain; } return conf; }
static void *mod_mapcache_merge_server_conf(apr_pool_t *p, void *base_, void *vhost_) { mapcache_server_cfg *base = (mapcache_server_cfg*)base_; mapcache_server_cfg *vhost = (mapcache_server_cfg*)vhost_; mapcache_server_cfg *cfg = apr_pcalloc(p,sizeof(mapcache_server_cfg)); if (base->aliases && vhost->aliases) { cfg->aliases = apr_hash_overlay(p, vhost->aliases,base->aliases); } else if (vhost->aliases) { cfg->aliases = apr_hash_copy(p,vhost->aliases); } else if (base->aliases) { cfg->aliases = apr_hash_copy(p,base->aliases); } return vhost; }
static void overlay_2unique(abts_case *tc, void *data) { apr_hash_t *base = NULL; apr_hash_t *overlay = NULL; apr_hash_t *result = NULL; int count; char StrArray[MAX_DEPTH][MAX_LTH]; base = apr_hash_make(p); overlay = apr_hash_make(p); ABTS_PTR_NOTNULL(tc, base); ABTS_PTR_NOTNULL(tc, overlay); apr_hash_set(base, "base1", APR_HASH_KEY_STRING, "value1"); apr_hash_set(base, "base2", APR_HASH_KEY_STRING, "value2"); apr_hash_set(base, "base3", APR_HASH_KEY_STRING, "value3"); apr_hash_set(base, "base4", APR_HASH_KEY_STRING, "value4"); apr_hash_set(base, "base5", APR_HASH_KEY_STRING, "value5"); apr_hash_set(overlay, "overlay1", APR_HASH_KEY_STRING, "value1"); apr_hash_set(overlay, "overlay2", APR_HASH_KEY_STRING, "value2"); apr_hash_set(overlay, "overlay3", APR_HASH_KEY_STRING, "value3"); apr_hash_set(overlay, "overlay4", APR_HASH_KEY_STRING, "value4"); apr_hash_set(overlay, "overlay5", APR_HASH_KEY_STRING, "value5"); result = apr_hash_overlay(p, overlay, base); count = apr_hash_count(result); ABTS_INT_EQUAL(tc, 10, count); dump_hash(p, result, StrArray); ABTS_STR_EQUAL(tc, "Key base1 (5) Value value1\n", StrArray[0]); ABTS_STR_EQUAL(tc, "Key base2 (5) Value value2\n", StrArray[1]); ABTS_STR_EQUAL(tc, "Key base3 (5) Value value3\n", StrArray[2]); ABTS_STR_EQUAL(tc, "Key base4 (5) Value value4\n", StrArray[3]); ABTS_STR_EQUAL(tc, "Key base5 (5) Value value5\n", StrArray[4]); ABTS_STR_EQUAL(tc, "Key overlay1 (8) Value value1\n", StrArray[5]); ABTS_STR_EQUAL(tc, "Key overlay2 (8) Value value2\n", StrArray[6]); ABTS_STR_EQUAL(tc, "Key overlay3 (8) Value value3\n", StrArray[7]); ABTS_STR_EQUAL(tc, "Key overlay4 (8) Value value4\n", StrArray[8]); ABTS_STR_EQUAL(tc, "Key overlay5 (8) Value value5\n", StrArray[9]); ABTS_STR_EQUAL(tc, "#entries 10\n", StrArray[10]); }
static void *h2_config_merge(apr_pool_t *pool, void *basev, void *addv) { h2_config *base = (h2_config *)basev; h2_config *add = (h2_config *)addv; h2_config *n = (h2_config *)apr_pcalloc(pool, sizeof(h2_config)); char *name = apr_pstrcat(pool, "merged[", add->name, ", ", base->name, "]", NULL); n->name = name; n->h2_max_streams = H2_CONFIG_GET(add, base, h2_max_streams); n->h2_window_size = H2_CONFIG_GET(add, base, h2_window_size); n->min_workers = H2_CONFIG_GET(add, base, min_workers); n->max_workers = H2_CONFIG_GET(add, base, max_workers); n->max_worker_idle_secs = H2_CONFIG_GET(add, base, max_worker_idle_secs); n->stream_max_mem_size = H2_CONFIG_GET(add, base, stream_max_mem_size); n->alt_svcs = add->alt_svcs? add->alt_svcs : base->alt_svcs; n->alt_svc_max_age = H2_CONFIG_GET(add, base, alt_svc_max_age); n->serialize_headers = H2_CONFIG_GET(add, base, serialize_headers); n->h2_direct = H2_CONFIG_GET(add, base, h2_direct); n->modern_tls_only = H2_CONFIG_GET(add, base, modern_tls_only); n->h2_upgrade = H2_CONFIG_GET(add, base, h2_upgrade); n->tls_warmup_size = H2_CONFIG_GET(add, base, tls_warmup_size); n->tls_cooldown_secs = H2_CONFIG_GET(add, base, tls_cooldown_secs); n->h2_push = H2_CONFIG_GET(add, base, h2_push); if (add->priorities && base->priorities) { n->priorities = apr_hash_overlay(pool, add->priorities, base->priorities); } else { n->priorities = add->priorities? add->priorities : base->priorities; } n->push_diary_size = H2_CONFIG_GET(add, base, push_diary_size); n->copy_files = H2_CONFIG_GET(add, base, copy_files); if (add->push_list && base->push_list) { n->push_list = apr_array_append(pool, base->push_list, add->push_list); } else { n->push_list = add->push_list? add->push_list : base->push_list; } n->early_hints = H2_CONFIG_GET(add, base, early_hints); return n; }
static void overlay_fetch(abts_case *tc, void *data) { apr_hash_t *base = NULL; apr_hash_t *overlay = NULL; apr_hash_t *result = NULL; int count; base = apr_hash_make(p); overlay = apr_hash_make(p); ABTS_PTR_NOTNULL(tc, base); ABTS_PTR_NOTNULL(tc, overlay); apr_hash_set(base, "base1", APR_HASH_KEY_STRING, "value1"); apr_hash_set(base, "base2", APR_HASH_KEY_STRING, "value2"); apr_hash_set(base, "base3", APR_HASH_KEY_STRING, "value3"); apr_hash_set(base, "base4", APR_HASH_KEY_STRING, "value4"); apr_hash_set(base, "base5", APR_HASH_KEY_STRING, "value5"); apr_hash_set(overlay, "overlay1", APR_HASH_KEY_STRING, "value1"); apr_hash_set(overlay, "overlay2", APR_HASH_KEY_STRING, "value2"); apr_hash_set(overlay, "overlay3", APR_HASH_KEY_STRING, "value3"); apr_hash_set(overlay, "overlay4", APR_HASH_KEY_STRING, "value4"); apr_hash_set(overlay, "overlay5", APR_HASH_KEY_STRING, "value5"); result = apr_hash_overlay(p, overlay, base); count = apr_hash_count(result); ABTS_INT_EQUAL(tc, 10, count); ABTS_STR_EQUAL(tc, "value1", apr_hash_get(result, "base1", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value2", apr_hash_get(result, "base2", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value3", apr_hash_get(result, "base3", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value4", apr_hash_get(result, "base4", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value5", apr_hash_get(result, "base5", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value1", apr_hash_get(result, "overlay1", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value2", apr_hash_get(result, "overlay2", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value3", apr_hash_get(result, "overlay3", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value4", apr_hash_get(result, "overlay4", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value5", apr_hash_get(result, "overlay5", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value1", apr_hash_get(base, "base1", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value2", apr_hash_get(base, "base2", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value3", apr_hash_get(base, "base3", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value4", apr_hash_get(base, "base4", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value5", apr_hash_get(base, "base5", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value1", apr_hash_get(overlay, "overlay1", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value2", apr_hash_get(overlay, "overlay2", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value3", apr_hash_get(overlay, "overlay3", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value4", apr_hash_get(overlay, "overlay4", APR_HASH_KEY_STRING)); ABTS_STR_EQUAL(tc, "value5", apr_hash_get(overlay, "overlay5", APR_HASH_KEY_STRING)); }