1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* 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_portable.h"
18
#include "apr_strings.h"
19
#include "apr_arch_dso.h"
25
APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso,
26
apr_os_dso_handle_t osdso,
29
*aprdso = apr_pcalloc(pool, sizeof **aprdso);
30
(*aprdso)->handle = osdso;
31
(*aprdso)->pool = pool;
35
APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso,
36
apr_dso_handle_t *aprdso)
38
*osdso = aprdso->handle;
42
static apr_status_t dso_cleanup(void *thedso)
44
apr_dso_handle_t *dso = thedso;
50
rc = dllfree(dso->handle);
56
dso->failing_errno = errno;
60
APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle,
61
const char *path, apr_pool_t *ctx)
66
*res_handle = apr_pcalloc(ctx, sizeof(*res_handle));
67
(*res_handle)->pool = ctx;
68
if ((handle = dllload(path)) != NULL) {
69
(*res_handle)->handle = handle;
70
apr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, apr_pool_cleanup_null);
74
(*res_handle)->failing_errno = errno;
78
APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle)
80
return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup);
83
APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym,
84
apr_dso_handle_t *handle,
90
if ((var_ptr = dllqueryvar(handle->handle, symname)) != NULL) {
94
if ((func_ptr = (void *)dllqueryfn(handle->handle, symname)) != NULL) {
98
handle->failing_errno = errno;
102
APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *handle, char *buffer,
105
apr_cpystrn(buffer, strerror(handle->failing_errno), buflen);