annotate src/sysdll.c @ 276:6330739388db r21-0b36

Import from CVS: tag r21-0b36
author cvs
date Mon, 13 Aug 2007 10:30:37 +0200
parents c5d627a313b1
children 8626e4521993
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 <stdlib.h>
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
27 #include <assert.h>
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
28 #include <string.h>
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
29 #include <stdio.h>
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
30 #include "sysdll.h"
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
31
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
32 /* This whole file is conditional upon HAVE_DLL */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
33 #ifdef HAVE_SHLIB
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
34
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
35 /* Thankfully, most systems follow the ELFish dlopen() method.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
36 ** HAVE__DLOPEN is lame, but SCO has their dl* functions as _dl*, and
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
37 ** 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
38 ** autoconf fails to find them.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
39 **
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
40 ** 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
41 ** look for _dlopen() as well as dlopen()
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
42 */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
43 #if defined(HAVE_DLOPEN) || defined(HAVE__DLOPEN)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
44 #include <dlfcn.h>
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_LAZY
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
47 # define RTLD_LAZY 1
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
48 #endif /* RTLD_LAZY isn't defined under FreeBSD - ick */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
49
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
50 #ifndef RTLD_GLOBAL
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
51 # define RTLD_GLOBAL 0
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
52 #endif
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
53
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
54 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
55 dll_init (CONST char *arg)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
56 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
57 return 0;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
58 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
59
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
60 dll_handle
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
61 dll_open (CONST char *fname)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
62 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
63 return (dll_handle)dlopen (fname, RTLD_LAZY | RTLD_GLOBAL);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
64 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
65
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
66 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
67 dll_close (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
68 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
69 return dlclose((void *)h);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
70 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
71
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
72 dll_func
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
73 dll_function (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
74 {
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
75 #ifdef DLSYM_NEEDS_UNDERSCORE
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
76 char *buf = alloca_array (char, strlen (n) + 2);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
77 *buf = '_';
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
78 (void)strcpy(buf + 1, n);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
79 n = buf;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
80 #endif
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
81 return (dll_func)dlsym ((void *)h, n);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
82 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
83
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
84 dll_var
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
85 dll_variable (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
86 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
87 return (dll_var)dlsym ((void *)h, n);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
88 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
89
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
90 CONST char *
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
91 dll_error (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
92 {
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
93 #ifdef HAVE_DLERROR
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
94 return (CONST char *)dlerror ();
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
95 #else
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
96 return "Shared library error";
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
97 #endif
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
98 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
99
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
100 #elif defined(HAVE_SHL_LOAD)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
101 /* This is the HP/UX version */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
102 #include <dl.h>
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
103 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
104 dll_init (CONST char *arg)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
105 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
106 return 0;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
107 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
108
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
109 dll_handle
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
110 dll_open (CONST char *fname)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
111 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
112 shl_t h = shl_load (fname, BIND_DEFERRED,0L);
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 265
diff changeset
113 shl_t *hp = NULL;
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 265
diff changeset
114
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
115 if (h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
116 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
117 hp = (shl_t *)malloc (sizeof (shl_t));
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
118 if (!hp)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
119 shl_unload(h);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
120 else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
121 *hp = h;
267
966663fcf606 Import from CVS: tag r20-5b32
cvs
parents: 265
diff changeset
122 }
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
123 return (dll_handle)hp;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
124 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
125
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
126 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
127 dll_close (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
128 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 267
diff changeset
129 shl_t hp = *((shl_t *)h);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
130 free (hp);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
131 return shl_unload(h);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
132 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
133
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
134 dll_func
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
135 dll_function (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
136 {
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
137 long handle = 0L;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
138
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
139 if (shl_findsym ((shl_t *)h, n, TYPE_PROCEDURE, &handle))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
140 return NULL;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
141
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
142 return (dll_func)handle;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
143 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
144
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
145 dll_var
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
146 dll_variable (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
147 {
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
148 long handle = 0L;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
149
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
150 if (shl_findsym ((shl_t *)h, n, TYPE_DATA, &handle))
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
151 return NULL;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
152
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
153 return (dll_var)handle;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
154 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
155
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
156 CONST char *
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
157 dll_error (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
158 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
159 /* #### WTF?! Shouldn't this at least attempt to get strerror or
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
160 something? --hniksic */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
161 return "Generic shared library error";
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
162 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
163
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
164 #elif defined(HAVE_INIT_DLD)
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
165 #include <dld.h>
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
166 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
167 dll_init (CONST char *arg)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
168 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
169 char *real_exe = dld_find_executable (arg);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
170 int rc;
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
171
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
172 rc = dld_init (real_exe);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
173 if (rc)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
174 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
175 dld_perror (exe);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
176 return -1;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
177 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
178 return 0;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
179 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
180
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
181 dll_handle
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
182 dll_open (CONST char *fname)
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 rc = dld_link (fname);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
185 if (rc)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
186 return NULL;
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 return (dll_handle)1;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
189 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
190
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
191 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
192 dll_close (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
193 {
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
194 /* *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
195 ** later on to free the file - you have to remember the filename and
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
196 ** use that as the unlinker. We should eventually keep a linked list
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
197 ** of loaded modules and then use the node pointer as the unique id
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
198 ** for the shared library. Wheeee. But not now.
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
199 */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
200 return 1;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
201 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
202
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
203 DLL_FUNC
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
204 dll_function (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
205 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
206 return dld_get_func(n);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
207 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
208
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
209 DLL_FUNC
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
210 dll_variable (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
211 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
212 return dld_get_symbol(n);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
213 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
214 #elif defined(_WINDOWS) || defined(WIN32)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
215 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
216 dll_init (CONST char *arg)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
217 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
218 return 0;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
219 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
220
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
221 dll_handle
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
222 dll_open (CONST char *fname)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
223 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
224 return (dll_handle)LoadLibrary (fname);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
225 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
226
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
227 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
228 dll_close (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
229 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
230 return FreeLibrary (h);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
231 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
232
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
233 dll_func
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
234 dll_function (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
235 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
236 return (dll_func)GetProcAddress (h,n);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
237 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
238
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
239 dll_func
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
240 dll_variable (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
241 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
242 return (dll_func)GetProcAddress (h,n);
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
243 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
244
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
245 CONST char *
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
246 dll_error (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
247 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
248 return "Windows DLL Error";
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
249 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
250 #else
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
251 /* 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
252 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
253 dll_init (CONST char *arg)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
254 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
255 return -1;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
256 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
257
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
258 dll_handle
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
259 dll_open (CONST char *fname)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
260 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
261 return NULL;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
262 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
263
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
264 int
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
265 dll_close (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
266 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
267 return 0;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
268 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
269
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
270 dll_func
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
271 dll_function (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
272 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
273 return NULL;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
274 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
275
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
276 dll_func
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
277 dll_variable (dll_handle h, CONST char *n)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
278 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
279 return NULL;
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
280 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
281
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
282 CONST char *
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
283 dll_error (dll_handle h)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
284 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
285 return "Shared libraries not implemented on this system";
265
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
286 }
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
287 #endif /* System conditionals */
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
288
8efd647ea9ca Import from CVS: tag r20-5b31
cvs
parents:
diff changeset
289 #endif /* HAVE_SHLIB */