? unxmacxp.pro Index: checkdll/checkdll.c =================================================================== RCS file: /cvs/oo/tools/soltools/checkdll/checkdll.c,v retrieving revision 1.3 diff -u -r1.3 checkdll.c --- checkdll/checkdll.c 2001/08/28 11:15:18 1.3 +++ checkdll/checkdll.c 2002/06/05 21:55:02 @@ -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) { - printf(": ok\n"); - CFRelease(bundlePath); - CFRelease(bundleURL); - CFRelease(bundle); - CFRelease(symbolName); - return 0; - } - 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 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); + // 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"); +#ifdef NO_UNLOAD_CHECK + _exit(0); +#else + // Mac OS X can't unload dylibs +#endif + return 0; + } else { + printf(": ERROR: symbol %s not found\n", psymbol); + } + } else { + printf(": ERROR: %s is not a valid dylib name\n", argv[1]); + } return 3; + + // fixme use NSLinkEditError() for better error messages #else /* MACOSX */ Index: mkdepend/def.h =================================================================== RCS file: /cvs/oo/tools/soltools/mkdepend/def.h,v retrieving revision 1.2 diff -u -r1.2 def.h --- mkdepend/def.h 2002/01/16 11:57:26 1.2 +++ mkdepend/def.h 2002/06/05 21:55:04 @@ -47,7 +47,14 @@ #endif #include #include + #include + +#ifdef MACOSX +/* Need to define these because sys/stat.h is bad */ +#define S_IFDIR 0040000 /* directory */ +#define S_IFREG 0100000 /* regular */ +#endif /* MACOSX */ #define MAXDEFINES 512 #define MAXFILES 2048 /* Increased from 512. -mcafee */