2 * $Id: module.c,v 1.5 2003-02-17 02:03:12 srittau Exp $
7 #endif /* HAVE_CONFIG_H */
11 #include <atalk/util.h>
15 #include <mach-o/dyld.h>
17 void *mod_open(const char *path)
19 NSObjectFileImage file;
21 if (NSCreateObjectFileImageFromFile(path, &file) !=
22 NSObjectFileImageSuccess)
24 return NSLinkModule(file, path, TRUE);
27 void *mod_symbol(void *module, const char *name)
32 if ((underscore = (char *) malloc(strlen(name) + 2)) == NULL)
34 strcpy(underscore, "_");
35 strcat(underscore, name);
36 symbol = NSLookupAndBindSymbol(underscore);
39 return NSAddressOfSymbol(symbol);
42 void mod_close(void *module)
44 NSUnLinkModule(module, FALSE);
46 #endif /* MACOSX_SERVER */
48 #else /* HAVE_DLFCN_H */
52 #ifdef DLSYM_PREPEND_UNDERSCORE
53 void *mod_symbol(void *module, const char *name)
61 if ((underscore = (char *) malloc(strlen(name) + 2)) == NULL)
64 strcpy(underscore, "_");
65 strcat(underscore, name);
66 symbol = dlsym(module, underscore);
71 #endif /* DLSYM_PREPEND_UNDERSCORE */
72 #endif /* HAVE_DLFCN_H */