/* OSGLUCCO.m Copyright (C) 2012 Paul C. Pratt, SDL by Sam Lantinga and others You can redistribute this file and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. You should have received a copy of the license along with this file; see the file COPYING. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.*/ /* Operating System GLUe for mac os CoCOa All operating system dependent code for the Mac OS Cocoa should go here. Originally derived from Cocoa port of SDL Library by Sam Lantinga (but little trace of that remains).*/ #include "CNFGRAPI.h"#include "SYSDEPNS.h"#include "ENDIANAC.h" #include "MYOSGLUE.h" #include "STRCONST.h" /* --- adapting to API/ABI version differences --- */ #ifndef MAC_OS_X_VERSION_10_5#define MAC_OS_X_VERSION_10_5 1050#endif #ifndef MAC_OS_X_VERSION_10_6#define MAC_OS_X_VERSION_10_6 1060#endif #ifndef WantGraphicsSwitching#define WantGraphicsSwitching 0#endif #if MAC_OS_X_VERSION_10_5 > MAC_OS_X_VERSION_MAX_ALLOWED typedef unsigned long NSUInteger;typedef long NSInteger; typedef struct __CFError * CFErrorRef; #if WantGraphicsSwitching#define NSOpenGLPFAAllowOfflineRenderers \ (NSOpenGLPixelFormatAttribute)96#endif #endif #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED @protocol NSWindowDelegate <NSObject> @end@protocol NSApplicationDelegate <NSObject> @end #endif LOCALVAR CFBundleRef AppServBunRef; LOCALVAR blnr DidApplicationServicesBun = falseblnr; LOCALFUNC blnr HaveApplicationServicesBun(void){ if (! DidApplicationServicesBun) { AppServBunRef = CFBundleGetBundleWithIdentifier( CFSTR("com.apple.ApplicationServices")); DidApplicationServicesBun = trueblnr; } return (AppServBunRef != NULL);} #if MayFullScreen LOCALVAR CFBundleRef HIToolboxBunRef; LOCALVAR blnr DidHIToolboxBunRef = falseblnr; LOCALFUNC blnr HaveHIToolboxBunRef(void){ if (! DidHIToolboxBunRef) { HIToolboxBunRef = CFBundleGetBundleWithIdentifier( CFSTR("com.apple.HIToolbox")); DidHIToolboxBunRef = trueblnr; } return (HIToolboxBunRef != NULL);} #endif #if MayFullScreen /* SetSystemUIModeProcPtr API always not available */ typedef UInt32 MySystemUIMode;typedef OptionBits MySystemUIOptions; enum { MykUIModeNormal = 0, MykUIModeAllHidden = 3}; enum { MykUIOptionAutoShowMenuBar = 1 << 0, MykUIOptionDisableAppleMenu = 1 << 2, MykUIOptionDisableProcessSwitch = 1 << 3, MykUIOptionDisableForceQuit = 1 << 4, MykUIOptionDisableSessionTerminate = 1 << 5, MykUIOptionDisableHide = 1 << 6}; typedef OSStatus (*SetSystemUIModeProcPtr) (MySystemUIMode inMode, MySystemUIOptions inOptions);LOCALVAR SetSystemUIModeProcPtr MySetSystemUIMode = NULL;LOCALVAR blnr DidSetSystemUIMode = falseblnr; LOCALFUNC blnr HaveMySetSystemUIMode(void){ if (! DidSetSystemUIMode) { if (HaveHIToolboxBunRef()) { MySetSystemUIMode = (SetSystemUIModeProcPtr) CFBundleGetFunctionPointerForName( HIToolboxBunRef, CFSTR("SetSystemUIMode")); } DidSetSystemUIMode = trueblnr; } return (MySetSystemUIMode != NULL);} #endif typedef Boolean (*CFURLCopyResourcePropertyForKeyProcPtr) ( CFURLRef url, CFStringRef key, void *propertyValueTypeRefPtr, CFErrorRef *error );LOCALVAR CFURLCopyResourcePropertyForKeyProcPtr MyCFURLCopyResourcePropertyForKey = NULL;LOCALVAR blnr DidCFURLCopyResourcePropertyForKey = falseblnr; LOCALFUNC blnr HaveMyCFURLCopyResourcePropertyForKey(void){ if (! DidCFURLCopyResourcePropertyForKey) { if (HaveApplicationServicesBun()) { MyCFURLCopyResourcePropertyForKey = (CFURLCopyResourcePropertyForKeyProcPtr) CFBundleGetFunctionPointerForName( AppServBunRef, CFSTR("CFURLCopyResourcePropertyForKey")); } DidCFURLCopyResourcePropertyForKey = trueblnr; } return (MyCFURLCopyResourcePropertyForKey != NULL);} LOCALVAR const CFStringRef *MykCFURLIsAliasFileKey = NULL;LOCALVAR blnr DidkCFURLIsAliasFileKey = falseblnr; LOCALFUNC blnr HaveMykCFURLIsAliasFileKey(void){ if (! DidkCFURLIsAliasFileKey) { if (HaveApplicationServicesBun()) { MykCFURLIsAliasFileKey = (const CFStringRef *) CFBundleGetDataPointerForName( AppServBunRef, CFSTR("kCFURLIsAliasFileKey")); } DidkCFURLIsAliasFileKey = trueblnr; } return (MykCFURLIsAliasFileKey != NULL);} LOCALVAR const CFStringRef *MykCFURLIsSymbolicLinkKey = NULL;LOCALVAR blnr DidkCFURLIsSymbolicLinkKey = falseblnr; LOCALFUNC blnr HaveMykCFURLIsSymbolicLinkKey(void){ if (! DidkCFURLIsSymbolicLinkKey) { if (HaveApplicationServicesBun()) { MykCFURLIsSymbolicLinkKey = (const CFStringRef *) CFBundleGetDataPointerForName( AppServBunRef, CFSTR("kCFURLIsSymbolicLinkKey")); } DidkCFURLIsSymbolicLinkKey = trueblnr; } return (MykCFURLIsSymbolicLinkKey != NULL);} typedef CFDataRef (*CFURLCreateBookmarkDataFromFileProcPtr) ( CFAllocatorRef allocator, CFURLRef fileURL, CFErrorRef *errorRef);LOCALVAR CFURLCreateBookmarkDataFromFileProcPtr MyCFURLCreateBookmarkDataFromFile = NULL;LOCALVAR blnr DidCFURLCreateBookmarkDataFromFile = falseblnr; LOCALFUNC blnr HaveMyCFURLCreateBookmarkDataFromFile(void){ if (! DidCFURLCreateBookmarkDataFromFile) { if (HaveApplicationServicesBun()) { MyCFURLCreateBookmarkDataFromFile = (CFURLCreateBookmarkDataFromFileProcPtr) CFBundleGetFunctionPointerForName(AppServBunRef, CFSTR("CFURLCreateBookmarkDataFromFile")); } DidCFURLCreateBookmarkDataFromFile = trueblnr; } return (MyCFURLCreateBookmarkDataFromFile != NULL);} typedef CFOptionFlags MyCFURLBookmarkResolutionOptions; typedef CFURLRef (*CFURLCreateByResolvingBookmarkDataProcPtr) ( CFAllocatorRef allocator, CFDataRef bookmark, MyCFURLBookmarkResolutionOptions options, CFURLRef relativeToURL, CFArrayRef resourcePropertiesToInclude, Boolean* isStale, CFErrorRef* error);LOCALVAR CFURLCreateByResolvingBookmarkDataProcPtr MyCFURLCreateByResolvingBookmarkData = NULL;LOCALVAR blnr DidCFURLCreateByResolvingBookmarkData = falseblnr; LOCALFUNC blnr HaveMyCFURLCreateByResolvingBookmarkData(void){ if (! DidCFURLCreateByResolvingBookmarkData) { if (HaveApplicationServicesBun()) { MyCFURLCreateByResolvingBookmarkData = (CFURLCreateByResolvingBookmarkDataProcPtr) CFBundleGetFunctionPointerForName(AppServBunRef, CFSTR("CFURLCreateByResolvingBookmarkData")); } DidCFURLCreateByResolvingBookmarkData = trueblnr; } return (MyCFURLCreateByResolvingBookmarkData != NULL);} typedef boolean_t (*CGCursorIsVisibleProcPtr)(void); LOCALVAR CGCursorIsVisibleProcPtr MyCGCursorIsVisible = NULL;LOCALVAR blnr DidCGCursorIsVisible = falseblnr; LOCALFUNC blnr HaveMyCGCursorIsVisible(void){ if (! DidCGCursorIsVisible) { if (HaveApplicationServicesBun()) { MyCGCursorIsVisible = (CGCursorIsVisibleProcPtr) CFBundleGetFunctionPointerForName( AppServBunRef, CFSTR("CGCursorIsVisible")); } DidCGCursorIsVisible = trueblnr; } return (MyCGCursorIsVisible != NULL);} /* --- some simple utilities --- */ GLOBALOSGLUPROC MyMoveBytes(anyp srcPtr, anyp destPtr, si5b byteCount){ (void) memcpy((char *)destPtr, (char *)srcPtr, byteCount);} /* --- control mode and internationalization --- */ #define NeedCell2UnicodeMap 1 #include "INTLCHAR.h" /* --- sending debugging info to file --- */ LOCALVAR NSString *myAppName = nil;LOCALVAR NSString *MyDataPath = nil; #if dbglog_HAVE #define dbglog_ToStdErr 0 #if ! dbglog_ToStdErrLOCALVAR FILE *dbglog_File = NULL;#endif LOCALFUNC blnr dbglog_open0(void){#if dbglog_ToStdErr return trueblnr;#else NSString *myLogPath = [MyDataPath stringByAppendingPathComponent: @"dbglog.txt"]; const char *path = [myLogPath fileSystemRepresentation]; dbglog_File = fopen(path, "w"); return (NULL != dbglog_File);#endif} LOCALPROC dbglog_write0(char *s, uimr L){#if dbglog_ToStdErr (void) fwrite(s, 1, L, stderr);#else if (NULL != dbglog_File) { (void) fwrite(s, 1, L, dbglog_File); }#endif} LOCALPROC dbglog_close0(void){#if ! dbglog_ToStdErr if (NULL != dbglog_File) { fclose(dbglog_File); dbglog_File = NULL; }#endif} #endif /* --- information about the environment --- */ #define WantColorTransValid 1 #include "COMOSGLU.h" #define WantKeyboard_RemapMac 1 #include "PBUFSTDC.h" #include "CONTROLM.h" /* --- text translation --- */ LOCALPROC UniCharStrFromSubstCStr(int *L, unichar *x, char *s){ int i; int L0; ui3b ps[ClStrMaxLength]; ClStrFromSubstCStr(&L0, ps, s); for (i = 0; i < L0; ++i) { x[i] = Cell2UnicodeMap[ps[i]]; } *L = L0;} LOCALFUNC NSString * NSStringCreateFromSubstCStr(char *s){ int L; unichar x[ClStrMaxLength]; UniCharStrFromSubstCStr(&L, x, s); return [NSString stringWithCharacters:x length:L];} #if IncludeSonyNameNewLOCALFUNC blnr MacRomanFileNameToNSString(tPbuf i, NSString **r){ ui3p p; void *Buffer = PbufDat[i]; ui5b L = PbufSize[i]; p = (ui3p)malloc(L /* + 1 */); if (p != NULL) { NSData *d; ui3b *p0 = (ui3b *)Buffer; ui3b *p1 = (ui3b *)p; if (L > 0) { ui5b j = L; do { ui3b x = *p0++; if (x < 32) { x = '-'; } else if (x >= 128) { } else { switch (x) { case '/': case '<': case '>': case '|': case ':': x = '-'; default: break; } } *p1++ = x; } while (--j > 0); if ('.' == p[0]) { p[0] = '-'; } } #if 0 *p1 = 0; *r = [NSString stringWithCString:(char *)p encoding:NSMacOSRomanStringEncoding]; /* only as of OS X 10.4 */ free(p);#endif d = [[NSData alloc] initWithBytesNoCopy:p length:L]; *r = [[[NSString alloc] initWithData:d encoding:NSMacOSRomanStringEncoding] autorelease]; [d release]; return trueblnr; } return falseblnr;}#endif #if IncludeSonyGetName || IncludeHostTextClipExchangeLOCALFUNC tMacErr NSStringToRomanPbuf(NSString *string, tPbuf *r){ tMacErr v = mnvm_miscErr; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];#if 0 const char *s = [s0 cStringUsingEncoding: NSMacOSRomanStringEncoding]; ui5r L = strlen(s); /* only as of OS X 10.4 */#endif#if 0 NSData *d0 = [string dataUsingEncoding: NSMacOSRomanStringEncoding];#endif NSData *d0 = [string dataUsingEncoding: NSMacOSRomanStringEncoding allowLossyConversion: YES]; const void *s = [d0 bytes]; NSUInteger L = [d0 length]; if (NULL == s) { v = mnvm_miscErr; } else { ui3p p = (ui3p)malloc(L); if (NULL == p) { v = mnvm_miscErr; } else { /* memcpy((char *)p, s, L); */ ui3b *p0 = (ui3b *)s; ui3b *p1 = (ui3b *)p; int i; for (i = L; --i >= 0; ) { ui3b v = *p0++; if (10 == v) { v = 13; } *p1++ = v; } v = PbufNewFromPtr(p, L, r); } } [pool release]; return v;}#endif /* --- drives --- */ LOCALFUNC blnr FindNamedChildPath(NSString *parentPath, char *ChildName, NSString **childPath)Lines 1–500 of 4993. Load more
/* OSGLUCCO.m Copyright (C) 2012 Paul C. Pratt, SDL by Sam Lantinga and others You can redistribute this file and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. You should have received a copy of the license along with this file; see the file COPYING. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ /* Operating System GLUe for mac os CoCOa All operating system dependent code for the Mac OS Cocoa should go here. Originally derived from Cocoa port of SDL Library by Sam Lantinga (but little trace of that remains). */ #include "CNFGRAPI.h" #include "SYSDEPNS.h" #include "ENDIANAC.h" #include "MYOSGLUE.h" #include "STRCONST.h" /* --- adapting to API/ABI version differences --- */ #ifndef MAC_OS_X_VERSION_10_5 #define MAC_OS_X_VERSION_10_5 1050 #endif #ifndef MAC_OS_X_VERSION_10_6 #define MAC_OS_X_VERSION_10_6 1060 #endif #ifndef WantGraphicsSwitching #define WantGraphicsSwitching 0 #endif #if MAC_OS_X_VERSION_10_5 > MAC_OS_X_VERSION_MAX_ALLOWED typedef unsigned long NSUInteger; typedef long NSInteger; typedef struct __CFError * CFErrorRef; #if WantGraphicsSwitching #define NSOpenGLPFAAllowOfflineRenderers \ (NSOpenGLPixelFormatAttribute)96 #endif #endif #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED @protocol NSWindowDelegate <NSObject> @end @protocol NSApplicationDelegate <NSObject> @end #endif LOCALVAR CFBundleRef AppServBunRef; LOCALVAR blnr DidApplicationServicesBun = falseblnr; LOCALFUNC blnr HaveApplicationServicesBun(void) { if (! DidApplicationServicesBun) { AppServBunRef = CFBundleGetBundleWithIdentifier( CFSTR("com.apple.ApplicationServices")); DidApplicationServicesBun = trueblnr; } return (AppServBunRef != NULL); } #if MayFullScreen LOCALVAR CFBundleRef HIToolboxBunRef; LOCALVAR blnr DidHIToolboxBunRef = falseblnr; LOCALFUNC blnr HaveHIToolboxBunRef(void) { if (! DidHIToolboxBunRef) { HIToolboxBunRef = CFBundleGetBundleWithIdentifier( CFSTR("com.apple.HIToolbox")); DidHIToolboxBunRef = trueblnr; } return (HIToolboxBunRef != NULL); } #endif #if MayFullScreen /* SetSystemUIModeProcPtr API always not available */ typedef UInt32 MySystemUIMode; typedef OptionBits MySystemUIOptions; enum { MykUIModeNormal = 0, MykUIModeAllHidden = 3 }; enum { MykUIOptionAutoShowMenuBar = 1 << 0, MykUIOptionDisableAppleMenu = 1 << 2, MykUIOptionDisableProcessSwitch = 1 << 3, MykUIOptionDisableForceQuit = 1 << 4, MykUIOptionDisableSessionTerminate = 1 << 5, MykUIOptionDisableHide = 1 << 6 }; typedef OSStatus (*SetSystemUIModeProcPtr) (MySystemUIMode inMode, MySystemUIOptions inOptions); LOCALVAR SetSystemUIModeProcPtr MySetSystemUIMode = NULL; LOCALVAR blnr DidSetSystemUIMode = falseblnr; LOCALFUNC blnr HaveMySetSystemUIMode(void) { if (! DidSetSystemUIMode) { if (HaveHIToolboxBunRef()) { MySetSystemUIMode = (SetSystemUIModeProcPtr) CFBundleGetFunctionPointerForName( HIToolboxBunRef, CFSTR("SetSystemUIMode")); } DidSetSystemUIMode = trueblnr; } return (MySetSystemUIMode != NULL); } #endif typedef Boolean (*CFURLCopyResourcePropertyForKeyProcPtr) ( CFURLRef url, CFStringRef key, void *propertyValueTypeRefPtr, CFErrorRef *error ); LOCALVAR CFURLCopyResourcePropertyForKeyProcPtr MyCFURLCopyResourcePropertyForKey = NULL; LOCALVAR blnr DidCFURLCopyResourcePropertyForKey = falseblnr; LOCALFUNC blnr HaveMyCFURLCopyResourcePropertyForKey(void) { if (! DidCFURLCopyResourcePropertyForKey) { if (HaveApplicationServicesBun()) { MyCFURLCopyResourcePropertyForKey = (CFURLCopyResourcePropertyForKeyProcPtr) CFBundleGetFunctionPointerForName( AppServBunRef, CFSTR("CFURLCopyResourcePropertyForKey")); } DidCFURLCopyResourcePropertyForKey = trueblnr; } return (MyCFURLCopyResourcePropertyForKey != NULL); } LOCALVAR const CFStringRef *MykCFURLIsAliasFileKey = NULL; LOCALVAR blnr DidkCFURLIsAliasFileKey = falseblnr; LOCALFUNC blnr HaveMykCFURLIsAliasFileKey(void) { if (! DidkCFURLIsAliasFileKey) { if (HaveApplicationServicesBun()) { MykCFURLIsAliasFileKey = (const CFStringRef *) CFBundleGetDataPointerForName( AppServBunRef, CFSTR("kCFURLIsAliasFileKey")); } DidkCFURLIsAliasFileKey = trueblnr; } return (MykCFURLIsAliasFileKey != NULL); } LOCALVAR const CFStringRef *MykCFURLIsSymbolicLinkKey = NULL; LOCALVAR blnr DidkCFURLIsSymbolicLinkKey = falseblnr; LOCALFUNC blnr HaveMykCFURLIsSymbolicLinkKey(void) { if (! DidkCFURLIsSymbolicLinkKey) { if (HaveApplicationServicesBun()) { MykCFURLIsSymbolicLinkKey = (const CFStringRef *) CFBundleGetDataPointerForName( AppServBunRef, CFSTR("kCFURLIsSymbolicLinkKey")); } DidkCFURLIsSymbolicLinkKey = trueblnr; } return (MykCFURLIsSymbolicLinkKey != NULL); } typedef CFDataRef (*CFURLCreateBookmarkDataFromFileProcPtr) ( CFAllocatorRef allocator, CFURLRef fileURL, CFErrorRef *errorRef); LOCALVAR CFURLCreateBookmarkDataFromFileProcPtr MyCFURLCreateBookmarkDataFromFile = NULL; LOCALVAR blnr DidCFURLCreateBookmarkDataFromFile = falseblnr; LOCALFUNC blnr HaveMyCFURLCreateBookmarkDataFromFile(void) { if (! DidCFURLCreateBookmarkDataFromFile) { if (HaveApplicationServicesBun()) { MyCFURLCreateBookmarkDataFromFile = (CFURLCreateBookmarkDataFromFileProcPtr) CFBundleGetFunctionPointerForName(AppServBunRef, CFSTR("CFURLCreateBookmarkDataFromFile")); } DidCFURLCreateBookmarkDataFromFile = trueblnr; } return (MyCFURLCreateBookmarkDataFromFile != NULL); } typedef CFOptionFlags MyCFURLBookmarkResolutionOptions; typedef CFURLRef (*CFURLCreateByResolvingBookmarkDataProcPtr) ( CFAllocatorRef allocator, CFDataRef bookmark, MyCFURLBookmarkResolutionOptions options, CFURLRef relativeToURL, CFArrayRef resourcePropertiesToInclude, Boolean* isStale, CFErrorRef* error); LOCALVAR CFURLCreateByResolvingBookmarkDataProcPtr MyCFURLCreateByResolvingBookmarkData = NULL; LOCALVAR blnr DidCFURLCreateByResolvingBookmarkData = falseblnr; LOCALFUNC blnr HaveMyCFURLCreateByResolvingBookmarkData(void) { if (! DidCFURLCreateByResolvingBookmarkData) { if (HaveApplicationServicesBun()) { MyCFURLCreateByResolvingBookmarkData = (CFURLCreateByResolvingBookmarkDataProcPtr) CFBundleGetFunctionPointerForName(AppServBunRef, CFSTR("CFURLCreateByResolvingBookmarkData")); } DidCFURLCreateByResolvingBookmarkData = trueblnr; } return (MyCFURLCreateByResolvingBookmarkData != NULL); } typedef boolean_t (*CGCursorIsVisibleProcPtr)(void); LOCALVAR CGCursorIsVisibleProcPtr MyCGCursorIsVisible = NULL; LOCALVAR blnr DidCGCursorIsVisible = falseblnr; LOCALFUNC blnr HaveMyCGCursorIsVisible(void) { if (! DidCGCursorIsVisible) { if (HaveApplicationServicesBun()) { MyCGCursorIsVisible = (CGCursorIsVisibleProcPtr) CFBundleGetFunctionPointerForName( AppServBunRef, CFSTR("CGCursorIsVisible")); } DidCGCursorIsVisible = trueblnr; } return (MyCGCursorIsVisible != NULL); } /* --- some simple utilities --- */ GLOBALOSGLUPROC MyMoveBytes(anyp srcPtr, anyp destPtr, si5b byteCount) { (void) memcpy((char *)destPtr, (char *)srcPtr, byteCount); } /* --- control mode and internationalization --- */ #define NeedCell2UnicodeMap 1 #include "INTLCHAR.h" /* --- sending debugging info to file --- */ LOCALVAR NSString *myAppName = nil; LOCALVAR NSString *MyDataPath = nil; #if dbglog_HAVE #define dbglog_ToStdErr 0 #if ! dbglog_ToStdErr LOCALVAR FILE *dbglog_File = NULL; #endif LOCALFUNC blnr dbglog_open0(void) { #if dbglog_ToStdErr return trueblnr; #else NSString *myLogPath = [MyDataPath stringByAppendingPathComponent: @"dbglog.txt"]; const char *path = [myLogPath fileSystemRepresentation]; dbglog_File = fopen(path, "w"); return (NULL != dbglog_File); #endif } LOCALPROC dbglog_write0(char *s, uimr L) { #if dbglog_ToStdErr (void) fwrite(s, 1, L, stderr); #else if (NULL != dbglog_File) { (void) fwrite(s, 1, L, dbglog_File); } #endif } LOCALPROC dbglog_close0(void) { #if ! dbglog_ToStdErr if (NULL != dbglog_File) { fclose(dbglog_File); dbglog_File = NULL; } #endif } #endif /* --- information about the environment --- */ #define WantColorTransValid 1 #include "COMOSGLU.h" #define WantKeyboard_RemapMac 1 #include "PBUFSTDC.h" #include "CONTROLM.h" /* --- text translation --- */ LOCALPROC UniCharStrFromSubstCStr(int *L, unichar *x, char *s) { int i; int L0; ui3b ps[ClStrMaxLength]; ClStrFromSubstCStr(&L0, ps, s); for (i = 0; i < L0; ++i) { x[i] = Cell2UnicodeMap[ps[i]]; } *L = L0; } LOCALFUNC NSString * NSStringCreateFromSubstCStr(char *s) { int L; unichar x[ClStrMaxLength]; UniCharStrFromSubstCStr(&L, x, s); return [NSString stringWithCharacters:x length:L]; } #if IncludeSonyNameNew LOCALFUNC blnr MacRomanFileNameToNSString(tPbuf i, NSString **r) { ui3p p; void *Buffer = PbufDat[i]; ui5b L = PbufSize[i]; p = (ui3p)malloc(L /* + 1 */); if (p != NULL) { NSData *d; ui3b *p0 = (ui3b *)Buffer; ui3b *p1 = (ui3b *)p; if (L > 0) { ui5b j = L; do { ui3b x = *p0++; if (x < 32) { x = '-'; } else if (x >= 128) { } else { switch (x) { case '/': case '<': case '>': case '|': case ':': x = '-'; default: break; } } *p1++ = x; } while (--j > 0); if ('.' == p[0]) { p[0] = '-'; } } #if 0 *p1 = 0; *r = [NSString stringWithCString:(char *)p encoding:NSMacOSRomanStringEncoding]; /* only as of OS X 10.4 */ free(p); #endif d = [[NSData alloc] initWithBytesNoCopy:p length:L]; *r = [[[NSString alloc] initWithData:d encoding:NSMacOSRomanStringEncoding] autorelease]; [d release]; return trueblnr; } return falseblnr; } #endif #if IncludeSonyGetName || IncludeHostTextClipExchange LOCALFUNC tMacErr NSStringToRomanPbuf(NSString *string, tPbuf *r) { tMacErr v = mnvm_miscErr; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; #if 0 const char *s = [s0 cStringUsingEncoding: NSMacOSRomanStringEncoding]; ui5r L = strlen(s); /* only as of OS X 10.4 */ #endif #if 0 NSData *d0 = [string dataUsingEncoding: NSMacOSRomanStringEncoding]; #endif NSData *d0 = [string dataUsingEncoding: NSMacOSRomanStringEncoding allowLossyConversion: YES]; const void *s = [d0 bytes]; NSUInteger L = [d0 length]; if (NULL == s) { v = mnvm_miscErr; } else { ui3p p = (ui3p)malloc(L); if (NULL == p) { v = mnvm_miscErr; } else { /* memcpy((char *)p, s, L); */ ui3b *p0 = (ui3b *)s; ui3b *p1 = (ui3b *)p; int i; for (i = L; --i >= 0; ) { ui3b v = *p0++; if (10 == v) { v = 13; } *p1++ = v; } v = PbufNewFromPtr(p, L, r); } } [pool release]; return v; } #endif /* --- drives --- */ LOCALFUNC blnr FindNamedChildPath(NSString *parentPath, char *ChildName, NSString **childPath)