bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / srclib / apr / dso / beos / dso.c
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 "beos/apr_arch_dso.h"
18 #include "apr_portable.h"
19
20 #if APR_HAS_DSO
21
22 static apr_status_t dso_cleanup(void *thedso)
23 {
24     apr_dso_handle_t *dso = thedso;
25
26     if (dso->handle > 0 && unload_add_on(dso->handle) < B_NO_ERROR)
27         return APR_EINIT;
28     dso->handle = -1;
29
30     return APR_SUCCESS;
31 }
32
33 APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, 
34                                        const char *path, apr_pool_t *pool)
35 {
36     image_id newid;
37
38     if((newid = load_add_on(path)) < B_NO_ERROR)
39         return APR_EDSOOPEN;
40
41     *res_handle = apr_pcalloc(pool, sizeof(*res_handle));
42     (*res_handle)->handle = newid;
43     (*res_handle)->pool = pool;
44
45     apr_pool_cleanup_register(pool, *res_handle, dso_cleanup, apr_pool_cleanup_null);
46
47     return APR_SUCCESS;
48 }
49
50 APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle)
51 {
52     return apr_pool_cleanup_run(handle->pool, handle, dso_cleanup);
53 }
54
55 APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, apr_dso_handle_t *handle,
56                const char *symname)
57 {
58     int err;
59
60     if (symname == NULL)
61         return APR_ESYMNOTFOUND;
62
63     err = get_image_symbol(handle->handle, symname, B_SYMBOL_TYPE_ANY, 
64                          ressym);
65
66     if(err != B_OK)
67         return APR_ESYMNOTFOUND;
68
69     return APR_SUCCESS;
70 }
71
72 APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, apr_size_t buflen)
73 {
74     strncpy(buffer, strerror(errno), buflen);
75     return buffer;
76 }
77
78 APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **aprdso,
79                                                 apr_os_dso_handle_t osdso,
80                                                 apr_pool_t *pool)
81 {
82     *aprdso = apr_pcalloc(pool, sizeof **aprdso);
83     (*aprdso)->handle = osdso;
84     (*aprdso)->pool = pool;
85     return APR_SUCCESS;
86 }
87
88 APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *osdso,
89                                                 apr_dso_handle_t *aprdso)
90 {
91     *osdso = aprdso->handle;
92     return APR_SUCCESS;
93 }
94
95 #endif