2 * $Id: module.c,v 1.3 2001-06-20 14:51:13 rufustfirefly Exp $
7 #endif /* HAVE_CONFIG_H */
11 #include <atalk/util.h>
13 static int _mod_dummy;
17 #include <mach-o/dyld.h>
19 void *mod_open(const char *path)
21 NSObjectFileImage file;
23 if (NSCreateObjectFileImageFromFile(path, &file) !=
24 NSObjectFileImageSuccess)
26 return NSLinkModule(file, path, TRUE);
29 void *mod_symbol(void *module, const char *name)
34 if ((underscore = (char *) malloc(strlen(name) + 2)) == NULL)
36 strcpy(underscore, "_");
37 strcat(underscore, name);
38 symbol = NSLookupAndBindSymbol(underscore);
41 return NSAddressOfSymbol(symbol);
44 void mod_close(void *module)
46 NSUnLinkModule(module, FALSE);
48 #endif /* MACOSX_SERVER */
50 #else /* HAVE_DLFCN_H */
52 #ifdef DLSYM_PREPEND_UNDERSCORE
55 void *mod_symbol(void *module, const char *name)
63 if ((underscore = (char *) malloc(strlen(name) + 2)) == NULL)
66 strcpy(underscore, "_");
67 strcat(underscore, name);
68 symbol = dlsym(module, underscore);
73 #endif /* DLSYM_PREPEND_UNDERSCORE */
74 #endif /* HAVE_DLFCN_H */