annotate src/sysdll.c @ 388:aabb7f5b1c81 r21-2-9

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