annotate src/sysdll.c @ 430:a5df635868b2 r21-2-23

Import from CVS: tag r21-2-23
author cvs
date Mon, 13 Aug 2007 11:29:08 +0200
parents 3ecd8885ac67
children abe6d1db359e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* sysdll.c --- system dependent support for dynamic linked libraries
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1998 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Author: William Perry <wmperry@aventail.com>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to the Free
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
26 #include <stdlib.h>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include "sysdll.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 /* This whole file is conditional upon HAVE_SHLIB */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #ifdef HAVE_SHLIB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 /* Thankfully, most systems follow the ELFish dlopen() method.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 ** HAVE__DLOPEN is lame, but SCO has their dl* functions as _dl*, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ** unless you include dlfcn.h you don't get the macros to mask them, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ** autoconf fails to find them. No longer true as of 5.0.5.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 **
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 ** Anybody who wants to use this on SCO needs to have their configure.in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 ** look for _dlopen() as well as dlopen()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #if defined(HAVE_DLOPEN) || defined(HAVE__DLOPEN) || defined(HAVE_DLFCN_H)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #include <dlfcn.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #ifndef RTLD_LAZY
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 # define RTLD_LAZY 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 #endif /* RTLD_LAZY isn't defined under FreeBSD - ick */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #ifndef RTLD_GLOBAL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 # define RTLD_GLOBAL 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 dll_init (CONST char *arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 dll_handle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 dll_open (CONST char *fname)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 return (dll_handle)dlopen (fname, RTLD_LAZY | RTLD_GLOBAL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 return dlclose((void *)h);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 dll_func
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 dll_function (dll_handle h, CONST char *n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 #ifdef DLSYM_NEEDS_UNDERSCORE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 char *buf = alloca_array (char, strlen (n) + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 *buf = '_';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 (void)strcpy(buf + 1, n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 n = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 return (dll_func)dlsym ((void *)h, n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 dll_var
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 dll_variable (dll_handle h, CONST char *n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #ifdef DLSYM_NEEDS_UNDERSCORE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 char *buf = alloca_array (char, strlen (n) + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 *buf = '_';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 (void)strcpy(buf + 1, n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 n = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 return (dll_var)dlsym ((void *)h, n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 CONST char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 dll_error (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 #if defined(HAVE_DLERROR) || defined(dlerror)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 return (CONST char *)dlerror ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 #elif defined(HAVE__DLERROR)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 return (const char *)_dlerror();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 return "Shared library error";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 #elif defined(HAVE_SHL_LOAD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 /* This is the HP/UX version */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 #include <dl.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 dll_init (CONST char *arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 dll_handle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 dll_open (CONST char *fname)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 shl_t h = shl_load (fname, BIND_DEFERRED,0L);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 shl_t *hp = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 if (h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 hp = (shl_t *)malloc (sizeof (shl_t));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 if (!hp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 shl_unload(h);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 *hp = h;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 return (dll_handle)hp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 shl_t hp = *((shl_t *)h);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 free (hp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 return shl_unload(h);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 dll_func
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 dll_function (dll_handle h, CONST char *n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 long handle = 0L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 if (shl_findsym ((shl_t *)h, n, TYPE_PROCEDURE, &handle))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 return (dll_func)handle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 dll_var
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 dll_variable (dll_handle h, CONST char *n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 long handle = 0L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 if (shl_findsym ((shl_t *)h, n, TYPE_DATA, &handle))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 return (dll_var)handle;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 CONST char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 dll_error (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 /* #### WTF?! Shouldn't this at least attempt to get strerror or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 something? --hniksic */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 return "Generic shared library error";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 #elif defined(HAVE_INIT_DLD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 #include <dld.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 dll_init (CONST char *arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 char *real_exe = dld_find_executable (arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 int rc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 rc = dld_init (real_exe);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 if (rc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 dld_perror (exe);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 dll_handle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 dll_open (CONST char *fname)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 rc = dld_link (fname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 if (rc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 return (dll_handle)1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 /* *sigh* DLD is pretty lame and doesn't return a handle that you can use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 ** later on to free the file - you have to remember the filename and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 ** use that as the unlinker. We should eventually keep a linked list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 ** of loaded modules and then use the node pointer as the unique id
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 ** for the shared library. Wheeee. But not now.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 DLL_FUNC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 dll_function (dll_handle h, CONST char *n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 return dld_get_func(n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 DLL_FUNC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 dll_variable (dll_handle h, CONST char *n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 return dld_get_symbol(n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 #elif defined(_WINDOWS) || defined(WIN32)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 dll_init (CONST char *arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 dll_handle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 dll_open (CONST char *fname)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 return (dll_handle)LoadLibrary (fname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 return FreeLibrary (h);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 dll_func
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 dll_function (dll_handle h, CONST char *n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 return (dll_func)GetProcAddress (h,n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 dll_func
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 dll_variable (dll_handle h, CONST char *n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 return (dll_func)GetProcAddress (h,n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 CONST char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 dll_error (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 return "Windows DLL Error";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 /* Catchall if we don't know about this systems method of dynamic loading */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 dll_init (CONST char *arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 dll_handle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 dll_open (CONST char *fname)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 dll_func
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 dll_function (dll_handle h, CONST char *n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 dll_func
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 dll_variable (dll_handle h, CONST char *n)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 CONST char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 dll_error (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 return "Shared libraries not implemented on this system";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 #endif /* System conditionals */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 #endif /* HAVE_SHLIB */