annotate src/sysdll.c @ 387:f892a9d0bb8d

Added tag r21-2-8 for changeset 4af0ddfb7c5b
author cvs
date Mon, 13 Aug 2007 11:08:51 +0200
parents 8626e4521993
children aabb7f5b1c81
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
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
28 /* This whole file is conditional upon HAVE_DLL */
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
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
34 ** autoconf fails to find them.
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 */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
39 #if defined(HAVE_DLOPEN) || defined(HAVE__DLOPEN)
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 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
83 return (dll_var)dlsym ((void *)h, n);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
84 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
85
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
86 CONST char *
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
87 dll_error (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
88 {
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
89 #ifdef HAVE_DLERROR
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
90 return (CONST char *)dlerror ();
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
91 #else
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
92 return "Shared library error";
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
93 #endif
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
94 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
95
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
96 #elif defined(HAVE_SHL_LOAD)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
97 /* This is the HP/UX version */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
98 #include <dl.h>
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
99 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
100 dll_init (CONST char *arg)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
101 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
102 return 0;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
103 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
104
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
105 dll_handle
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
106 dll_open (CONST char *fname)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
107 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
108 shl_t h = shl_load (fname, BIND_DEFERRED,0L);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 265
diff changeset
109 shl_t *hp = NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 265
diff changeset
110
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
111 if (h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
112 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
113 hp = (shl_t *)malloc (sizeof (shl_t));
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
114 if (!hp)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
115 shl_unload(h);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
116 else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
117 *hp = h;
267
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 return (dll_handle)hp;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
120 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
121
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
122 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
123 dll_close (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
124 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 267
diff changeset
125 shl_t hp = *((shl_t *)h);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
126 free (hp);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
127 return shl_unload(h);
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 dll_func
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
131 dll_function (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
132 {
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
133 long handle = 0L;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
134
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
135 if (shl_findsym ((shl_t *)h, n, TYPE_PROCEDURE, &handle))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
136 return NULL;
265
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 return (dll_func)handle;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
139 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
140
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
141 dll_var
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
142 dll_variable (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
143 {
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
144 long handle = 0L;
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 if (shl_findsym ((shl_t *)h, n, TYPE_DATA, &handle))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
147 return NULL;
265
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 return (dll_var)handle;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
150 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
151
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
152 CONST char *
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
153 dll_error (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
154 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
155 /* #### WTF?! Shouldn't this at least attempt to get strerror or
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
156 something? --hniksic */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
157 return "Generic shared library error";
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
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
160 #elif defined(HAVE_INIT_DLD)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
161 #include <dld.h>
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
162 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
163 dll_init (CONST char *arg)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
164 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
165 char *real_exe = dld_find_executable (arg);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
166 int rc;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
167
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
168 rc = dld_init (real_exe);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
169 if (rc)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
170 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
171 dld_perror (exe);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
172 return -1;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
173 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
174 return 0;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
175 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
176
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
177 dll_handle
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
178 dll_open (CONST char *fname)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
179 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
180 rc = dld_link (fname);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
181 if (rc)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
182 return NULL;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
183
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
184 return (dll_handle)1;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
185 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
186
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
187 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
188 dll_close (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
189 {
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
190 /* *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
191 ** later on to free the file - you have to remember the filename and
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
192 ** use that as the unlinker. We should eventually keep a linked list
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
193 ** of loaded modules and then use the node pointer as the unique id
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
194 ** for the shared library. Wheeee. But not now.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
195 */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
196 return 1;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
197 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
198
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
199 DLL_FUNC
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
200 dll_function (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
201 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
202 return dld_get_func(n);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
203 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
204
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
205 DLL_FUNC
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
206 dll_variable (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
207 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
208 return dld_get_symbol(n);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
209 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
210 #elif defined(_WINDOWS) || defined(WIN32)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
211 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
212 dll_init (CONST char *arg)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
213 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
214 return 0;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
215 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
216
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
217 dll_handle
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
218 dll_open (CONST char *fname)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
219 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
220 return (dll_handle)LoadLibrary (fname);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
221 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
222
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
223 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
224 dll_close (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
225 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
226 return FreeLibrary (h);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
227 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
228
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
229 dll_func
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
230 dll_function (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
231 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
232 return (dll_func)GetProcAddress (h,n);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
233 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
234
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
235 dll_func
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
236 dll_variable (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
237 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
238 return (dll_func)GetProcAddress (h,n);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
239 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
240
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
241 CONST char *
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
242 dll_error (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
243 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
244 return "Windows DLL Error";
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
245 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
246 #else
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
247 /* 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
248 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
249 dll_init (CONST char *arg)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
250 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
251 return -1;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
252 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
253
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
254 dll_handle
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
255 dll_open (CONST char *fname)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
256 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
257 return NULL;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
258 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
259
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
260 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
261 dll_close (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
262 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
263 return 0;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
264 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
265
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
266 dll_func
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
267 dll_function (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
268 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
269 return NULL;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
270 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
271
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
272 dll_func
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
273 dll_variable (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
274 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
275 return NULL;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
276 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
277
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
278 CONST char *
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
279 dll_error (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
280 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
281 return "Shared libraries not implemented on this system";
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
282 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
283 #endif /* System conditionals */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
284
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
285 #endif /* HAVE_SHLIB */