diff --git a/src/util/Platforms/MacOS/MacOSPlatformUtils.cpp b/src/util/Platforms/MacOS/MacOSPlatformUtils.cpp index e35fbf89d3d3b496f16947dcfda62762a7caf866..820621af9697085dde5a8d831031886954af7ce8 100644 --- a/src/util/Platforms/MacOS/MacOSPlatformUtils.cpp +++ b/src/util/Platforms/MacOS/MacOSPlatformUtils.cpp @@ -97,16 +97,27 @@ #include <memory> #include <algorithm> -#if TARGET_API_MAC_CARBON - #include <Carbon.h> +#if defined(XML_MACOSX) + // Include from Frameworks Headers under ProjectBuilder + #include <CarbonCore/Files.h> + #include <CarbonCore/Gestalt.h> + #include <CarbonCore/TextUtils.h> + #include <CarbonCore/TextEncodingConverter.h> + #include <CarbonCore/Multiprocessing.h> + #include <CarbonCore/DriverSynchronization.h> + #include <CarbonCore/DriverServices.h> + #include <CoreFoundation/CFString.h> + #include <URLAccess/URLAccess.h> #else - #include <Files.h> + // Classic include styles + #include <Files.h> #include <Gestalt.h> - #include <Traps.h> #include <TextUtils.h> #include <TextEncodingConverter.h> #include <Multiprocessing.h> #include <DriverSynchronization.h> + #include <DriverServices.h> + #include <CFString.h> #include <URLAccess.h> #endif @@ -374,17 +385,25 @@ XMLPlatformUtils::panic(const PanicReasons reason) else reasonStr = "Unknown error source"; - // - // This isn't real friendly and should be cleaned up. - // Replace this code to do whatever you need to do. - // char text[256]; std::snprintf(text, sizeof(text), "Xerces Panic Error: %s", reasonStr); + // + // The default handling of panics is not very friendly. + // To replace it with something more friendly, you'll need to: + // - #define XML_USE_CUSTOM_PANIC_PROC + // - Write, and link with, XMLCustomPanicProc + // - Implement your panic handling within XMLCustomPanicProc. + // +#if defined(XML_USE_CUSTOM_PANIC_PROC) + XMLCustomPanicProc(reason, reasonStr); +#else Str255 pasText; CopyCStringToPascal(text, pasText); DebugStr(pasText); +#endif + // Life's got us down. Good-bye world. std::exit(-1); } @@ -1235,7 +1254,7 @@ XMLParsePathToFSSpec_Classic(const XMLCh* const pathName, FSSpec& spec) // Update our spec if (err == noErr) - err = FSMakeFSSpec(spec.vRefNum, catInfo.dirInfo.ioDrParID, NULL, &spec); + err = FSMakeFSSpec(spec.vRefNum, catInfo.dirInfo.ioDrDirID, NULL, &spec); break; } diff --git a/src/util/Platforms/MacOS/MacOSPlatformUtils.hpp b/src/util/Platforms/MacOS/MacOSPlatformUtils.hpp index b2bd6d4528a3dba04dce4f6fb9810d5a95e25440..ce9aec74850b6da4b90a56cb16ae51edb5eee24e 100644 --- a/src/util/Platforms/MacOS/MacOSPlatformUtils.hpp +++ b/src/util/Platforms/MacOS/MacOSPlatformUtils.hpp @@ -63,9 +63,11 @@ #include <util/XercesDefs.hpp> #include <cstdlib> -#if TARGET_API_MAC_CARBON - #include <Carbon.h> +#if defined(XML_MACOSX) + // Framework includes from ProjectBuilder + #include <CarbonCore/Files.h> #else + // Classic includes otherwise #include <Files.h> #endif @@ -106,6 +108,16 @@ class XMLMacFile : public XMLMacAbstractFile }; +// +// Support for customized panic handling: +// The default handling of panics is not very friendly. +// To replace it with something more friendly, you'll need to: +// - #define XML_USE_CUSTOM_PANIC_PROC +// - Write, and link with, XMLCustomPanicProc +// - Implement your panic handling within XMLCustomPanicProc. +// +extern "C" void XMLCustomPanicProc(XMLPlatformUtils::PanicReasons panicReason, const char* reasonStr); + // Convert fom FSRef/FSSpec to a Unicode character string path. // Note that you'll need to delete [] that string after you're done with it! XMLCh* XMLCreateFullPathFromFSRef(const FSRef& startingRef);