OLD | NEW |
| (Empty) |
1 /* | |
2 Unix SMB/CIFS implementation. | |
3 Samba system utilities | |
4 Copyright (C) Andrew Tridgell 1992-1998 | |
5 Copyright (C) Jeremy Allison 1998-2002 | |
6 Copyright (C) Jelmer Vernooij 2006 | |
7 | |
8 ** NOTE! The following LGPL license applies to the replace | |
9 ** library. This does NOT imply that all of Samba is released | |
10 ** under the LGPL | |
11 | |
12 This library is free software; you can redistribute it and/or | |
13 modify it under the terms of the GNU Lesser General Public | |
14 License as published by the Free Software Foundation; either | |
15 version 3 of the License, or (at your option) any later version. | |
16 | |
17 This library is distributed in the hope that it will be useful, | |
18 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 Lesser General Public License for more details. | |
21 | |
22 You should have received a copy of the GNU Lesser General Public | |
23 License along with this library; if not, see <http://www.gnu.org/licenses/>. | |
24 */ | |
25 | |
26 #include "replace.h" | |
27 #ifdef HAVE_DL_H | |
28 #include <dl.h> | |
29 #endif | |
30 | |
31 #ifndef HAVE_DLOPEN | |
32 #ifdef DLOPEN_TAKES_UNSIGNED_FLAGS | |
33 void *rep_dlopen(const char *name, unsigned int flags) | |
34 #else | |
35 void *rep_dlopen(const char *name, int flags) | |
36 #endif | |
37 { | |
38 #ifdef HAVE_SHL_LOAD | |
39 if (name == NULL) | |
40 return PROG_HANDLE; | |
41 return (void *)shl_load(name, flags, 0); | |
42 #else | |
43 return NULL; | |
44 #endif | |
45 } | |
46 #endif | |
47 | |
48 #ifndef HAVE_DLSYM | |
49 void *rep_dlsym(void *handle, const char *symbol) | |
50 { | |
51 #ifdef HAVE_SHL_FINDSYM | |
52 void *sym_addr; | |
53 if (!shl_findsym((shl_t *)&handle, symbol, TYPE_UNDEFINED, &sym_addr)) | |
54 return sym_addr; | |
55 #endif | |
56 return NULL; | |
57 } | |
58 #endif | |
59 | |
60 #ifndef HAVE_DLERROR | |
61 char *rep_dlerror(void) | |
62 { | |
63 return "dynamic loading of objects not supported on this platform"; | |
64 } | |
65 #endif | |
66 | |
67 #ifndef HAVE_DLCLOSE | |
68 int rep_dlclose(void *handle) | |
69 { | |
70 #ifdef HAVE_SHL_CLOSE | |
71 return shl_unload((shl_t)handle); | |
72 #else | |
73 return 0; | |
74 #endif | |
75 } | |
76 #endif | |
OLD | NEW |