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_arch_dso.h"
18
#include "apr_strings.h"
19
#include "apr_portable.h"
25
static apr_status_t dso_cleanup(void *thedso)
27
apr_dso_handle_t *dso = thedso;
33
rc = DosFreeModule(dso->handle);
38
return APR_FROM_OS_ERROR(rc);
42
APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, const char *path, apr_pool_t *ctx)
44
char failed_module[200];
48
*res_handle = apr_pcalloc(ctx, sizeof(**res_handle));
49
(*res_handle)->cont = ctx;
50
(*res_handle)->load_error = APR_SUCCESS;
51
(*res_handle)->failed_module = NULL;
53
if ((rc = DosLoadModule(failed_module, sizeof(failed_module), path, &handle)) != 0) {
54
(*res_handle)->load_error = APR_FROM_OS_ERROR(rc);
55
(*res_handle)->failed_module = apr_pstrdup(ctx, failed_module);
56
return APR_FROM_OS_ERROR(rc);
59
(*res_handle)->handle = handle;
60
apr_pool_cleanup_register(ctx, *res_handle, dso_cleanup, apr_pool_cleanup_null);
66
APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle)
68
return apr_pool_cleanup_run(handle->cont, handle, dso_cleanup);
73
APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym,
74
apr_dso_handle_t *handle,
80
if (symname == NULL || ressym == NULL)
81
return APR_ESYMNOTFOUND;
83
if ((rc = DosQueryProcAddr(handle->handle, 0, symname, &func)) != 0) {
84
handle->load_error = APR_FROM_OS_ERROR(rc);
85
return handle->load_error;
94
APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, apr_size_t buflen)
97
apr_strerror(dso->load_error, message, sizeof(message));
99
if (dso->failed_module != NULL) {
100
strcat(message, " (");
101
strcat(message, dso->failed_module);
102
strcat(message, ")");
105
apr_cpystrn(buffer, message, buflen);
111
APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso,
112
apr_os_dso_handle_t osdso,
115
*aprdso = apr_pcalloc(pool, sizeof **aprdso);
116
(*aprdso)->handle = osdso;
117
(*aprdso)->cont = pool;
118
(*aprdso)->load_error = APR_SUCCESS;
119
(*aprdso)->failed_module = NULL;
125
APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso,
126
apr_dso_handle_t *aprdso)
128
*osdso = aprdso->handle;