1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "apr_pools.h"
20 #include "ap_provider.h"
22 static apr_hash_t *global_providers = NULL;
24 static apr_status_t cleanup_global_providers(void *ctx)
26 global_providers = NULL;
30 AP_DECLARE(apr_status_t) ap_register_provider(apr_pool_t *pool,
31 const char *provider_group,
32 const char *provider_name,
33 const char *provider_version,
36 apr_hash_t *provider_group_hash;
37 apr_hash_t *provider_version_hash;
39 if (global_providers == NULL) {
40 global_providers = apr_hash_make(pool);
41 apr_pool_cleanup_register(pool, NULL, cleanup_global_providers,
42 apr_pool_cleanup_null);
45 provider_group_hash = apr_hash_get(global_providers, provider_group,
48 if (!provider_group_hash) {
49 provider_group_hash = apr_hash_make(pool);
50 apr_hash_set(global_providers, provider_group, APR_HASH_KEY_STRING,
55 provider_version_hash = apr_hash_get(provider_group_hash, provider_name,
58 if (!provider_version_hash) {
59 provider_version_hash = apr_hash_make(pool);
60 apr_hash_set(provider_group_hash, provider_name, APR_HASH_KEY_STRING,
61 provider_version_hash);
65 /* just set it. no biggy if it was there before. */
66 apr_hash_set(provider_version_hash, provider_version, APR_HASH_KEY_STRING,
72 AP_DECLARE(void *) ap_lookup_provider(const char *provider_group,
73 const char *provider_name,
74 const char *provider_version)
76 apr_hash_t *provider_group_hash, *provider_name_hash;
78 if (global_providers == NULL) {
82 provider_group_hash = apr_hash_get(global_providers, provider_group,
85 if (provider_group_hash == NULL) {
89 provider_name_hash = apr_hash_get(provider_group_hash, provider_name,
92 if (provider_name_hash == NULL) {
96 return apr_hash_get(provider_name_hash, provider_version,