Only in .: .DS_Store diff -r -u /office/oo11/soltools/checkdll/checkdll.c ./checkdll/checkdll.c --- /office/oo11/soltools/checkdll/checkdll.c Sun Apr 20 10:55:54 2003 +++ ./checkdll/checkdll.c Thu Apr 24 23:20:20 2003 @@ -65,7 +65,7 @@ #include #include #ifdef MACOSX -#include +#include #else #include #endif @@ -90,10 +90,7 @@ { int rc; #ifdef MACOSX - CFStringRef bundlePath; - CFURLRef bundleURL; - CFBundleRef bundle; - CFStringRef symbolName; + struct mach_header *pLib; #else void *phandle; #endif @@ -115,45 +112,39 @@ #ifdef MACOSX - /* Convert char pointers to CFStringRefs */ - bundlePath = CFStringCreateWithCStringNoCopy(NULL, argv[1], - CFStringGetSystemEncoding(), kCFAllocatorNull); - symbolName = CFStringCreateWithCStringNoCopy(NULL, psymbol, - CFStringGetSystemEncoding(), kCFAllocatorNull); - - /* Get the framework's URL using its path */ - if ((bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, - bundlePath, kCFURLPOSIXPathStyle, true)) != NULL) { - /* Load the framework */ - if ((bundle = CFBundleCreate( kCFAllocatorDefault, - bundleURL)) != NULL) { - /* Load the shared library */ - if (CFBundleLoadExecutable(bundle)) { - if ((pfun = CFBundleGetFunctionPointerForName(bundle, - symbolName)) != NULL) { + // Check if library is already loaded + pLib = NSAddImage(argv[1], NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED); + if (!pLib) { + // Check DYLD_LIBRARY_PATH + pLib = NSAddImage(argv[1], NSADDIMAGE_OPTION_WITH_SEARCHING); + } + if (pLib) { + // Prefix symbol name with '_' + char *name = malloc(1+strlen(psymbol)+1); + NSSymbol *symbol; + void *address = NULL; + strcpy(name, "_"); + strcat(name, psymbol); + symbol = NSLookupSymbolInImage(pLib, name, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND); + free(name); + if (symbol) address = NSAddressOfSymbol(symbol); + if (address != NULL) { printf(": ok\n"); - CFRelease(bundlePath); - CFRelease(bundleURL); - CFRelease(bundle); - CFRelease(symbolName); +#ifdef NO_UNLOAD_CHECK + _exit(0); +#else + // Mac OS X can't unload dylibs +#endif return 0; - } - else + } else { printf(": ERROR: symbol %s not found\n", psymbol); } - /* No message printed since CFLog prints its own message */ + } else { + printf(": ERROR: %s is not a valid dylib name\n", argv[1]); } - else - printf(": ERROR: %s is not a bundle\n", argv[1]); - } - else - printf(": ERROR: %s is not a valid bundle name\n", argv[1]); - - CFRelease(bundlePath); - if (bundleURL != NULL) CFRelease(bundleURL); - if (bundle != NULL) CFRelease(bundle); - CFRelease(symbolName); return 3; + + // fixme use NSLinkEditError() for better error messages #else /* MACOSX */ Only in ./prj: .DS_Store