diff options
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/s_loader.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/src/s_loader.c | 175 |
1 files changed, 0 insertions, 175 deletions
diff --git a/apps/plugins/pdbox/PDa/src/s_loader.c b/apps/plugins/pdbox/PDa/src/s_loader.c index 78be948b93..c5a8677f71 100644 --- a/apps/plugins/pdbox/PDa/src/s_loader.c +++ b/apps/plugins/pdbox/PDa/src/s_loader.c | |||
@@ -161,178 +161,3 @@ int sys_load_lib(char *dirname, char *classname) | |||
161 | 161 | ||
162 | #endif | 162 | #endif |
163 | 163 | ||
164 | |||
165 | |||
166 | |||
167 | |||
168 | |||
169 | |||
170 | /* Copyright (c) 1997-1999 Miller Puckette. | ||
171 | * For information on usage and redistribution, and for a DISCLAIMER OF ALL | ||
172 | * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ | ||
173 | |||
174 | #ifdef DL_OPEN | ||
175 | #include <dlfcn.h> | ||
176 | #endif | ||
177 | #ifdef UNIX | ||
178 | #include <stdlib.h> | ||
179 | #include <unistd.h> | ||
180 | #endif | ||
181 | #ifdef MSW | ||
182 | #include <io.h> | ||
183 | #include <windows.h> | ||
184 | #endif | ||
185 | #ifdef MACOSX | ||
186 | #include <mach-o/dyld.h> | ||
187 | #endif | ||
188 | #include <string.h> | ||
189 | #include "m_pd.h" | ||
190 | #include "s_stuff.h" | ||
191 | #include <stdio.h> | ||
192 | |||
193 | typedef void (*t_xxx)(void); | ||
194 | |||
195 | static char sys_dllextent[] = | ||
196 | #ifdef __FreeBSD__ | ||
197 | ".pd_freebsd"; | ||
198 | #endif | ||
199 | #ifdef IRIX | ||
200 | #ifdef N32 | ||
201 | ".pd_irix6"; | ||
202 | #else | ||
203 | ".pd_irix5"; | ||
204 | #endif | ||
205 | #endif | ||
206 | #ifdef __linux__ | ||
207 | ".pd_linux"; | ||
208 | #endif | ||
209 | #ifdef MACOSX | ||
210 | ".pd_darwin"; | ||
211 | #endif | ||
212 | #ifdef MSW | ||
213 | ".dll"; | ||
214 | #endif | ||
215 | |||
216 | void class_set_extern_dir(t_symbol *s); | ||
217 | |||
218 | #ifdef STATIC | ||
219 | int sys_load_lib(char *dirname, char *classname) | ||
220 | { return 1;} | ||
221 | #else | ||
222 | int sys_load_lib(char *dirname, char *classname) | ||
223 | { | ||
224 | char symname[MAXPDSTRING], filename[MAXPDSTRING], dirbuf[MAXPDSTRING], | ||
225 | classname2[MAXPDSTRING], *nameptr, *lastdot; | ||
226 | void *dlobj; | ||
227 | t_xxx makeout = NULL; | ||
228 | int fd; | ||
229 | #ifdef MSW | ||
230 | HINSTANCE ntdll; | ||
231 | #endif | ||
232 | #if 0 | ||
233 | fprintf(stderr, "lib %s %s\n", dirname, classname); | ||
234 | #endif | ||
235 | /* try looking in the path for (classname).(sys_dllextent) ... */ | ||
236 | if ((fd = open_via_path(dirname, classname, sys_dllextent, | ||
237 | dirbuf, &nameptr, MAXPDSTRING, 1)) < 0) | ||
238 | { | ||
239 | /* next try (classname)/(classname).(sys_dllextent) ... */ | ||
240 | strncpy(classname2, classname, MAXPDSTRING); | ||
241 | filename[MAXPDSTRING-2] = 0; | ||
242 | strcat(classname2, "/"); | ||
243 | strncat(classname2, classname, MAXPDSTRING-strlen(classname2)); | ||
244 | filename[MAXPDSTRING-1] = 0; | ||
245 | if ((fd = open_via_path(dirname, classname2, sys_dllextent, | ||
246 | dirbuf, &nameptr, MAXPDSTRING, 1)) < 0) | ||
247 | { | ||
248 | return (0); | ||
249 | } | ||
250 | } | ||
251 | |||
252 | |||
253 | close(fd); | ||
254 | class_set_extern_dir(gensym(dirbuf)); | ||
255 | |||
256 | /* refabricate the pathname */ | ||
257 | strncpy(filename, dirbuf, MAXPDSTRING); | ||
258 | filename[MAXPDSTRING-2] = 0; | ||
259 | strcat(filename, "/"); | ||
260 | strncat(filename, nameptr, MAXPDSTRING-strlen(filename)); | ||
261 | filename[MAXPDSTRING-1] = 0; | ||
262 | /* extract the setup function name */ | ||
263 | if (lastdot = strrchr(nameptr, '.')) | ||
264 | *lastdot = 0; | ||
265 | |||
266 | #ifdef MACOSX | ||
267 | strcpy(symname, "_"); | ||
268 | strcat(symname, nameptr); | ||
269 | #else | ||
270 | strcpy(symname, nameptr); | ||
271 | #endif | ||
272 | /* if the last character is a tilde, replace with "_tilde" */ | ||
273 | if (symname[strlen(symname) - 1] == '~') | ||
274 | strcpy(symname + (strlen(symname) - 1), "_tilde"); | ||
275 | /* and append _setup to form the C setup function name */ | ||
276 | strcat(symname, "_setup"); | ||
277 | #ifdef DL_OPEN | ||
278 | dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); | ||
279 | if (!dlobj) | ||
280 | { | ||
281 | post("%s: %s", filename, dlerror()); | ||
282 | class_set_extern_dir(&s_); | ||
283 | return (0); | ||
284 | } | ||
285 | makeout = (t_xxx)dlsym(dlobj, symname); | ||
286 | #endif | ||
287 | #ifdef MSW | ||
288 | sys_bashfilename(filename, filename); | ||
289 | ntdll = LoadLibrary(filename); | ||
290 | if (!ntdll) | ||
291 | { | ||
292 | post("%s: couldn't load", filename); | ||
293 | class_set_extern_dir(&s_); | ||
294 | return (0); | ||
295 | } | ||
296 | makeout = (t_xxx)GetProcAddress(ntdll, symname); | ||
297 | #endif | ||
298 | #ifdef MACOSX | ||
299 | { | ||
300 | NSObjectFileImage image; | ||
301 | void *ret; | ||
302 | NSSymbol s; | ||
303 | if ( NSCreateObjectFileImageFromFile( filename, &image) != NSObjectFileImageSuccess ) | ||
304 | { | ||
305 | post("%s: couldn't load", filename); | ||
306 | class_set_extern_dir(&s_); | ||
307 | return 0; | ||
308 | } | ||
309 | ret = NSLinkModule( image, filename, | ||
310 | NSLINKMODULE_OPTION_BINDNOW + NSLINKMODULE_OPTION_PRIVATE); | ||
311 | |||
312 | s = NSLookupSymbolInModule(ret, symname); | ||
313 | |||
314 | if (s) | ||
315 | makeout = (t_xxx)NSAddressOfSymbol( s); | ||
316 | else makeout = 0; | ||
317 | } | ||
318 | #endif | ||
319 | |||
320 | if (!makeout) | ||
321 | { | ||
322 | post("load_object: Symbol \"%s\" not found", symname); | ||
323 | class_set_extern_dir(&s_); | ||
324 | return 0; | ||
325 | } | ||
326 | (*makeout)(); | ||
327 | class_set_extern_dir(&s_); | ||
328 | return (1); | ||
329 | } | ||
330 | |||
331 | #endif | ||
332 | |||
333 | |||
334 | |||
335 | |||
336 | |||
337 | |||
338 | |||