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 "jsvc.h"
18
19 #ifdef DSO_DLFCN
20 #include <dlfcn.h>
21 #ifdef OS_LINUX
22 bool ld_library_path_set = false;
23 #endif /* ifdef OS_LINUX */
24
25 /* Initialize all DSO stuff */
dso_init(void)26 bool dso_init(void)
27 {
28 return true;
29 }
30
31 /* Attempt to link a library from a specified filename */
dso_link(const char * path)32 dso_handle dso_link(const char *path)
33 {
34 log_debug("Attemtping to load library %s", path);
35
36 return ((void *)dlopen(path, RTLD_GLOBAL | RTLD_NOW));
37 }
38
39 /* Attempt to unload a library */
dso_unlink(dso_handle libr)40 bool dso_unlink(dso_handle libr)
41 {
42 if (dlclose(libr) == 0)
43 return true;
44 else
45 return false;
46 }
47
48 /* Get the address for a specifed symbol */
dso_symbol(dso_handle hdl,const char * nam)49 void *dso_symbol(dso_handle hdl, const char *nam)
50 {
51 return dlsym(hdl, nam);
52 }
53
54 /* Return the error message from dlopen */
dso_error(void)55 char *dso_error(void)
56 {
57 return (dlerror());
58 }
59
60 #endif /* ifdef DSO_DLFCN */
61