Apache HTTPD
dso.c
Go to the documentation of this file.
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#include "apr_arch_dso.h"
18#include "apr_strings.h"
19#include "apr_private.h"
20#include "apr_arch_file_io.h"
21#include "apr_arch_utf8.h"
22
23#if APR_HAS_DSO
24
28{
29 *aprdso = apr_pcalloc(pool, sizeof **aprdso);
30 (*aprdso)->handle = osdso;
31 (*aprdso)->cont = pool;
32 return APR_SUCCESS;
33}
34
37{
38 *osdso = aprdso->handle;
39 return APR_SUCCESS;
40}
41
43{
45
46 if (dso->handle != NULL && !FreeLibrary(dso->handle)) {
47 return apr_get_os_error();
48 }
49 dso->handle = NULL;
50
51 return APR_SUCCESS;
52}
53
55 const char *path, apr_pool_t *ctx)
56{
58 apr_status_t rv;
59#ifndef _WIN32_WCE
60 UINT em;
61#endif
62
63#if APR_HAS_UNICODE_FS
65 {
67 if ((rv = utf8_to_unicode_path(wpath, sizeof(wpath)
68 / sizeof(apr_wchar_t), path))
69 != APR_SUCCESS) {
70 *res_handle = apr_pcalloc(ctx, sizeof(**res_handle));
71 return ((*res_handle)->load_error = rv);
72 }
73 /* Prevent ugly popups from killing our app */
74#ifndef _WIN32_WCE
76#endif
78 if (!os_handle)
80 if (!os_handle)
81 rv = apr_get_os_error();
82#ifndef _WIN32_WCE
84#endif
85 }
86#endif /* APR_HAS_UNICODE_FS */
87#if APR_HAS_ANSI_FS
89 {
90 char fspec[APR_PATH_MAX], *p = fspec;
91 /* Must convert path from / to \ notation.
92 * Per PR2555, the LoadLibraryEx function is very picky about slashes.
93 * Debugging on NT 4 SP 6a reveals First Chance Exception within NTDLL.
94 * LoadLibrary in the MS PSDK also reveals that it -explicitly- states
95 * that backslashes must be used for the LoadLibrary family of calls.
96 */
97 apr_cpystrn(fspec, path, sizeof(fspec));
98 while ((p = strchr(p, '/')) != NULL)
99 *p = '\\';
100
101 /* Prevent ugly popups from killing our app */
104 if (!os_handle)
106 if (!os_handle)
107 rv = apr_get_os_error();
108 else
109 rv = APR_SUCCESS;
111 }
112#endif
113
114 *res_handle = apr_pcalloc(ctx, sizeof(**res_handle));
115 (*res_handle)->cont = ctx;
116
117 if (rv) {
118 return ((*res_handle)->load_error = rv);
119 }
120
121 (*res_handle)->handle = (void*)os_handle;
122 (*res_handle)->load_error = APR_SUCCESS;
123
125
126 return APR_SUCCESS;
127}
128
130{
132}
133
135 struct apr_dso_handle_t *handle,
136 const char *symname)
137{
138#ifdef _WIN32_WCE
139 apr_size_t symlen = strlen(symname) + 1;
140 apr_size_t wsymlen = 256;
142 apr_status_t rv;
143
145 if (rv != APR_SUCCESS) {
146 return rv;
147 }
148 else if (symlen) {
149 return APR_ENAMETOOLONG;
150 }
151
153#else
155#endif
156 if (!*ressym) {
157 return apr_get_os_error();
158 }
159 return APR_SUCCESS;
160}
161
163{
164 return apr_strerror(dso->load_error, buf, bufsize);
165}
166
167#endif
apr_uint16_t apr_wchar_t
#define LoadLibraryExW(nm, h, d)
APR Strings library.
request_rec int int apr_table_t const char * path
const unsigned char * buf
Definition util_md5.h:50
#define APR_ENAMETOOLONG
Definition apr_errno.h:655
apr_brigade_flush void * ctx
apr_pool_t const char apr_dbd_t ** handle
Definition apr_dbd.h:142
const void apr_status_t(*) apr_status_t(* APR_DECLARE)(void) apr_pool_pre_cleanup_register(apr_pool_t *p
Definition apr_pools.h:646
apr_size_t size
const char int apr_pool_t * pool
Definition apr_cstr.h:84
#define APR_SUCCESS
Definition apr_errno.h:225
#define apr_get_os_error()
Definition apr_errno.h:1217
char apr_size_t bufsize
Definition apr_errno.h:53
int apr_status_t
Definition apr_errno.h:44
#define apr_pcalloc(p, size)
Definition apr_pools.h:465
void * apr_os_dso_handle_t
apr_pool_t * p
Definition md_event.c:32
return NULL
Definition mod_so.c:359
static apr_status_t dso_cleanup(void *thedso)
Definition dso.c:41
#define ELSE_WIN_OS_IS_ANSI
#define IF_WIN_OS_IS_UNICODE