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.
19 #include "apu_config.h"
21 #include "apu_internal.h"
23 #include "apr_errno.h"
24 #include "apr_pools.h"
25 #include "apr_strings.h"
26 #include "apu_version.h"
32 static struct apr__ldap_dso_fntable *lfn = NULL;
34 static apr_status_t load_ldap(apr_pool_t *pool)
37 apr_dso_handle_sym_t symbol;
40 /* deprecate in 2.0 - permit implicit initialization */
43 rv = apu_dso_mutex_lock();
49 modname = "apr_ldap-" APU_STRINGIFY(APU_MAJOR_VERSION) ".dll";
51 modname = "apr_ldap-" APU_STRINGIFY(APU_MAJOR_VERSION) ".so";
53 rv = apu_dso_load(NULL, &symbol, modname, "apr__ldap_fns", pool);
54 if (rv == APR_SUCCESS) {
57 apu_dso_mutex_unlock();
62 #define LOAD_LDAP_STUB(pool, failres) \
63 if (!lfn && (load_ldap(pool) != APR_SUCCESS)) \
66 APU_DECLARE_LDAP(int) apr_ldap_info(apr_pool_t *pool,
67 apr_ldap_err_t **result_err)
69 LOAD_LDAP_STUB(pool, -1);
70 return lfn->info(pool, result_err);
73 APU_DECLARE_LDAP(int) apr_ldap_init(apr_pool_t *pool,
78 apr_ldap_err_t **result_err)
80 LOAD_LDAP_STUB(pool, -1);
81 return lfn->init(pool, ldap, hostname, portno, secure, result_err);
84 APU_DECLARE_LDAP(int) apr_ldap_ssl_init(apr_pool_t *pool,
85 const char *cert_auth_file,
87 apr_ldap_err_t **result_err)
89 LOAD_LDAP_STUB(pool, -1);
90 return lfn->ssl_init(pool, cert_auth_file, cert_file_type, result_err);
93 APU_DECLARE_LDAP(int) apr_ldap_ssl_deinit(void)
97 return lfn->ssl_deinit();
100 APU_DECLARE_LDAP(int) apr_ldap_get_option(apr_pool_t *pool,
104 apr_ldap_err_t **result_err)
106 LOAD_LDAP_STUB(pool, -1);
107 return lfn->get_option(pool, ldap, option, outvalue, result_err);
110 APU_DECLARE_LDAP(int) apr_ldap_set_option(apr_pool_t *pool,
114 apr_ldap_err_t **result_err)
116 LOAD_LDAP_STUB(pool, -1);
117 return lfn->set_option(pool, ldap, option, invalue, result_err);
120 APU_DECLARE_LDAP(apr_status_t) apr_ldap_rebind_init(apr_pool_t *pool)
122 LOAD_LDAP_STUB(pool, APR_EGENERAL);
123 return lfn->rebind_init(pool);
126 APU_DECLARE_LDAP(apr_status_t) apr_ldap_rebind_add(apr_pool_t *pool,
131 LOAD_LDAP_STUB(pool, APR_EGENERAL);
132 return lfn->rebind_add(pool, ld, bindDN, bindPW);
135 APU_DECLARE_LDAP(apr_status_t) apr_ldap_rebind_remove(LDAP *ld)
139 return lfn->rebind_remove(ld);
142 #endif /* APU_DSO_BUILD */
144 #endif /* APR_HAS_LDAP */