From f113f779502e08ed57f2c2c8a2ef65ebfff861fd Mon Sep 17 00:00:00 2001 From: su_v Date: Wed, 20 Aug 2014 03:15:30 +0200 Subject: Support compiling ScriptExec on newer versions of OS X (please review) (bzr r13506.1.6) --- .../ScriptExec/ScriptExec.xcode/project.pbxproj | 451 --------------------- .../ScriptExec.xcodeproj/project.pbxproj | 24 +- packaging/macosx/ScriptExec/main.c | 193 ++------- 3 files changed, 48 insertions(+), 620 deletions(-) delete mode 100644 packaging/macosx/ScriptExec/ScriptExec.xcode/project.pbxproj (limited to 'packaging') diff --git a/packaging/macosx/ScriptExec/ScriptExec.xcode/project.pbxproj b/packaging/macosx/ScriptExec/ScriptExec.xcode/project.pbxproj deleted file mode 100644 index bc081d5ef..000000000 --- a/packaging/macosx/ScriptExec/ScriptExec.xcode/project.pbxproj +++ /dev/null @@ -1,451 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 39; - objects = { - 0249A66BFF388E3F11CA2CEA = { - isa = PBXFileReference; - lastKnownFileType = archive.ar; - name = "libstdc++.a"; - path = "/usr/lib/libstdc++.a"; - refType = 0; - sourceTree = ""; - }; -//020 -//021 -//022 -//023 -//024 -//080 -//081 -//082 -//083 -//084 - 0867D6AAFE840B52C02AAC07 = { - children = ( - 0867D6ABFE840B52C02AAC07, - ); - isa = PBXVariantGroup; - name = InfoPlist.strings; - refType = 4; - sourceTree = ""; - }; - 0867D6ABFE840B52C02AAC07 = { - fileEncoding = 10; - isa = PBXFileReference; - lastKnownFileType = text.plist.strings; - name = English; - path = English.lproj/InfoPlist.strings; - refType = 4; - sourceTree = ""; - }; -//080 -//081 -//082 -//083 -//084 -//190 -//191 -//192 -//193 -//194 - 195DF8CFFE9D517E11CA2CBB = { - children = ( - 8D0C4E970486CD37000505A6, - ); - isa = PBXGroup; - name = Products; - refType = 4; - sourceTree = ""; - }; -//190 -//191 -//192 -//193 -//194 -//200 -//201 -//202 -//203 -//204 - 20286C28FDCF999611CA2CEA = { - buildSettings = { - }; - buildStyles = ( - 4A9504C5FFE6A39111CA0CBA, - 4A9504C6FFE6A39111CA0CBA, - ); - hasScannedForEncodings = 1; - isa = PBXProject; - mainGroup = 20286C29FDCF999611CA2CEA; - projectDirPath = ""; - targets = ( - 8D0C4E890486CD37000505A6, - ); - }; - 20286C29FDCF999611CA2CEA = { - children = ( - 20286C2AFDCF999611CA2CEA, - 20286C2CFDCF999611CA2CEA, - 20286C32FDCF999611CA2CEA, - 195DF8CFFE9D517E11CA2CBB, - ); - isa = PBXGroup; - name = ScriptExec; - path = ""; - refType = 4; - sourceTree = ""; - }; - 20286C2AFDCF999611CA2CEA = { - children = ( - 32DBCF6D0370B57F00C91783, - 20286C2BFDCF999611CA2CEA, - ); - isa = PBXGroup; - name = Sources; - path = ""; - refType = 4; - sourceTree = ""; - }; - 20286C2BFDCF999611CA2CEA = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.c; - path = main.c; - refType = 4; - sourceTree = ""; - }; - 20286C2CFDCF999611CA2CEA = { - children = ( - 664C29F0060ECDC4006EC560, - B8DCE042056DAC3500C390B0, - 8D0C4E960486CD37000505A6, - B8DCE048056DAC5000C390B0, - 0867D6AAFE840B52C02AAC07, - ); - isa = PBXGroup; - name = Resources; - path = ""; - refType = 4; - sourceTree = ""; - }; - 20286C32FDCF999611CA2CEA = { - children = ( - 20286C33FDCF999611CA2CEA, - 4A9504CAFFE6A41611CA0CBA, - 4A9504C8FFE6A3BC11CA0CBA, - 0249A66BFF388E3F11CA2CEA, - B8DCE04E056DACAE00C390B0, - ); - isa = PBXGroup; - name = "External Frameworks and Libraries"; - path = ""; - refType = 4; - sourceTree = ""; - }; - 20286C33FDCF999611CA2CEA = { - fallbackIsa = PBXFileReference; - isa = PBXFrameworkReference; - lastKnownFileType = wrapper.framework; - name = Carbon.framework; - path = /System/Library/Frameworks/Carbon.framework; - refType = 0; - sourceTree = ""; - }; -//200 -//201 -//202 -//203 -//204 -//320 -//321 -//322 -//323 -//324 - 32DBCF6D0370B57F00C91783 = { - fileEncoding = 4; - isa = PBXFileReference; - lastKnownFileType = sourcecode.c.h; - path = ScriptExec_Prefix.pch; - refType = 4; - sourceTree = ""; - }; -//320 -//321 -//322 -//323 -//324 -//4A0 -//4A1 -//4A2 -//4A3 -//4A4 - 4A9504C5FFE6A39111CA0CBA = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = NO; - DEBUGGING_SYMBOLS = YES; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - OPTIMIZATION_CFLAGS = "-O0"; - ZERO_LINK = YES; - }; - isa = PBXBuildStyle; - name = Development; - }; - 4A9504C6FFE6A39111CA0CBA = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = YES; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_OPTIMIZATION_LEVEL = s; - ZERO_LINK = NO; - }; - isa = PBXBuildStyle; - name = Deployment; - }; - 4A9504C8FFE6A3BC11CA0CBA = { - fallbackIsa = PBXFileReference; - isa = PBXFrameworkReference; - lastKnownFileType = wrapper.framework; - name = ApplicationServices.framework; - path = /System/Library/Frameworks/ApplicationServices.framework; - refType = 0; - sourceTree = ""; - }; - 4A9504CAFFE6A41611CA0CBA = { - fallbackIsa = PBXFileReference; - isa = PBXFrameworkReference; - lastKnownFileType = wrapper.framework; - name = CoreServices.framework; - path = /System/Library/Frameworks/CoreServices.framework; - refType = 0; - sourceTree = ""; - }; -//4A0 -//4A1 -//4A2 -//4A3 -//4A4 -//660 -//661 -//662 -//663 -//664 - 664C29F0060ECDC4006EC560 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = text.script.sh; - path = openDoc; - refType = 4; - sourceTree = ""; - }; - 664C29F1060ECDC4006EC560 = { - fileRef = 664C29F0060ECDC4006EC560; - isa = PBXBuildFile; - settings = { - }; - }; -//660 -//661 -//662 -//663 -//664 -//8D0 -//8D1 -//8D2 -//8D3 -//8D4 - 8D0C4E890486CD37000505A6 = { - buildPhases = ( - 8D0C4E8A0486CD37000505A6, - 8D0C4E8C0486CD37000505A6, - 8D0C4E8F0486CD37000505A6, - 8D0C4E910486CD37000505A6, - 8D0C4E940486CD37000505A6, - ); - buildRules = ( - ); - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ""; - GCC_ENABLE_TRIGRAPHS = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = ScriptExec_Prefix.pch; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; - GCC_WARN_UNKNOWN_PRAGMAS = NO; - HEADER_SEARCH_PATHS = ""; - INFOPLIST_FILE = Info.plist; - INSTALL_PATH = "$(HOME)/Applications"; - LIBRARY_SEARCH_PATHS = ""; - LIBRARY_STYLE = Static; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = ScriptExec; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; - WRAPPER_EXTENSION = app; - }; - dependencies = ( - ); - isa = PBXNativeTarget; - name = ScriptExec; - productInstallPath = "$(HOME)/Applications"; - productName = ScriptExec; - productReference = 8D0C4E970486CD37000505A6; - productType = "com.apple.product-type.application"; - }; - 8D0C4E8A0486CD37000505A6 = { - buildActionMask = 2147483647; - files = ( - 8D0C4E8B0486CD37000505A6, - ); - isa = PBXHeadersBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 8D0C4E8B0486CD37000505A6 = { - fileRef = 32DBCF6D0370B57F00C91783; - isa = PBXBuildFile; - settings = { - }; - }; - 8D0C4E8C0486CD37000505A6 = { - buildActionMask = 2147483647; - files = ( - 8D0C4E8D0486CD37000505A6, - B8DCE045056DAC3500C390B0, - B8DCE049056DAC5000C390B0, - 664C29F1060ECDC4006EC560, - ); - isa = PBXResourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 8D0C4E8D0486CD37000505A6 = { - fileRef = 0867D6AAFE840B52C02AAC07; - isa = PBXBuildFile; - settings = { - }; - }; - 8D0C4E8F0486CD37000505A6 = { - buildActionMask = 2147483647; - files = ( - 8D0C4E900486CD37000505A6, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 8D0C4E900486CD37000505A6 = { - fileRef = 20286C2BFDCF999611CA2CEA; - isa = PBXBuildFile; - settings = { - ATTRIBUTES = ( - ); - }; - }; - 8D0C4E910486CD37000505A6 = { - buildActionMask = 2147483647; - files = ( - 8D0C4E920486CD37000505A6, - 8D0C4E930486CD37000505A6, - B8DCE04F056DACAE00C390B0, - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 8D0C4E920486CD37000505A6 = { - fileRef = 20286C33FDCF999611CA2CEA; - isa = PBXBuildFile; - settings = { - }; - }; - 8D0C4E930486CD37000505A6 = { - fileRef = 0249A66BFF388E3F11CA2CEA; - isa = PBXBuildFile; - settings = { - }; - }; - 8D0C4E940486CD37000505A6 = { - buildActionMask = 2147483647; - files = ( - ); - isa = PBXRezBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 8D0C4E960486CD37000505A6 = { - fileEncoding = 4; - isa = PBXFileReference; - lastKnownFileType = text.plist; - path = Info.plist; - refType = 4; - sourceTree = ""; - }; - 8D0C4E970486CD37000505A6 = { - explicitFileType = wrapper.application; - includeInIndex = 0; - isa = PBXFileReference; - path = ScriptExec.app; - refType = 3; - sourceTree = BUILT_PRODUCTS_DIR; - }; -//8D0 -//8D1 -//8D2 -//8D3 -//8D4 -//B80 -//B81 -//B82 -//B83 -//B84 - B8DCE042056DAC3500C390B0 = { - isa = PBXFileReference; - lastKnownFileType = wrapper.nib; - path = MenuBar.nib; - refType = 4; - sourceTree = ""; - }; - B8DCE045056DAC3500C390B0 = { - fileRef = B8DCE042056DAC3500C390B0; - isa = PBXBuildFile; - settings = { - }; - }; - B8DCE048056DAC5000C390B0 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = text.script.sh; - path = script; - refType = 4; - sourceTree = ""; - }; - B8DCE049056DAC5000C390B0 = { - fileRef = B8DCE048056DAC5000C390B0; - isa = PBXBuildFile; - settings = { - }; - }; - B8DCE04E056DACAE00C390B0 = { - isa = PBXFileReference; - lastKnownFileType = wrapper.framework; - name = Security.framework; - path = /System/Library/Frameworks/Security.framework; - refType = 0; - sourceTree = ""; - }; - B8DCE04F056DACAE00C390B0 = { - fileRef = B8DCE04E056DACAE00C390B0; - isa = PBXBuildFile; - settings = { - }; - }; - }; - rootObject = 20286C28FDCF999611CA2CEA; -} diff --git a/packaging/macosx/ScriptExec/ScriptExec.xcodeproj/project.pbxproj b/packaging/macosx/ScriptExec/ScriptExec.xcodeproj/project.pbxproj index 3d0fe0120..0443dd764 100644 --- a/packaging/macosx/ScriptExec/ScriptExec.xcodeproj/project.pbxproj +++ b/packaging/macosx/ScriptExec/ScriptExec.xcodeproj/project.pbxproj @@ -12,14 +12,12 @@ 8D0C4E8D0486CD37000505A6 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */; }; 8D0C4E900486CD37000505A6 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 20286C2BFDCF999611CA2CEA /* main.c */; settings = {ATTRIBUTES = (); }; }; 8D0C4E920486CD37000505A6 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 20286C33FDCF999611CA2CEA /* Carbon.framework */; }; - 8D0C4E930486CD37000505A6 /* libstdc++.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0249A66BFF388E3F11CA2CEA /* libstdc++.a */; }; B8DCE045056DAC3500C390B0 /* MenuBar.nib in Resources */ = {isa = PBXBuildFile; fileRef = B8DCE042056DAC3500C390B0 /* MenuBar.nib */; }; B8DCE049056DAC5000C390B0 /* script in Resources */ = {isa = PBXBuildFile; fileRef = B8DCE048056DAC5000C390B0 /* script */; }; B8DCE04F056DACAE00C390B0 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B8DCE04E056DACAE00C390B0 /* Security.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 0249A66BFF388E3F11CA2CEA /* libstdc++.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libstdc++.a"; path = "/usr/lib/libstdc++.a"; sourceTree = ""; }; 0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; 20286C2BFDCF999611CA2CEA /* main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; 20286C33FDCF999611CA2CEA /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = ""; }; @@ -40,7 +38,6 @@ buildActionMask = 2147483647; files = ( 8D0C4E920486CD37000505A6 /* Carbon.framework in Frameworks */, - 8D0C4E930486CD37000505A6 /* libstdc++.a in Frameworks */, B8DCE04F056DACAE00C390B0 /* Security.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -94,7 +91,6 @@ 20286C33FDCF999611CA2CEA /* Carbon.framework */, 4A9504CAFFE6A41611CA0CBA /* CoreServices.framework */, 4A9504C8FFE6A3BC11CA0CBA /* ApplicationServices.framework */, - 0249A66BFF388E3F11CA2CEA /* libstdc++.a */, B8DCE04E056DACAE00C390B0 /* Security.framework */, ); name = "External Frameworks and Libraries"; @@ -140,9 +136,15 @@ 20286C28FDCF999611CA2CEA /* Project object */ = { isa = PBXProject; buildConfigurationList = 78E9AE1A0A36A8E3000D76A8 /* Build configuration list for PBXProject "ScriptExec" */; + compatibilityVersion = "Xcode 2.4"; + developmentRegion = English; hasScannedForEncodings = 1; + knownRegions = ( + en, + ); mainGroup = 20286C29FDCF999611CA2CEA /* ScriptExec */; projectDirPath = ""; + projectRoot = ""; targets = ( 8D0C4E890486CD37000505A6 /* ScriptExec */, ); @@ -199,6 +201,8 @@ 78E9AE170A36A8E3000D76A8 /* Development */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)"; + ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; COPY_PHASE_STRIP = NO; DEBUGGING_SYMBOLS = YES; FRAMEWORK_SEARCH_PATHS = ""; @@ -217,7 +221,6 @@ INSTALL_PATH = "$(HOME)/Applications"; LIBRARY_SEARCH_PATHS = ""; LIBRARY_STYLE = Static; - OPTIMIZATION_CFLAGS = "-O0"; OTHER_CFLAGS = ""; OTHER_LDFLAGS = ""; OTHER_REZFLAGS = ""; @@ -236,6 +239,8 @@ 78E9AE180A36A8E3000D76A8 /* Deployment */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)"; + ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; COPY_PHASE_STRIP = YES; FRAMEWORK_SEARCH_PATHS = ""; GCC_ENABLE_FIX_AND_CONTINUE = NO; @@ -270,6 +275,8 @@ 78E9AE190A36A8E3000D76A8 /* Default */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)"; + ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386"; FRAMEWORK_SEARCH_PATHS = ""; GCC_ENABLE_TRIGRAPHS = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; @@ -300,25 +307,18 @@ 78E9AE1B0A36A8E3000D76A8 /* Development */ = { isa = XCBuildConfiguration; buildSettings = { - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; }; name = Development; }; 78E9AE1C0A36A8E3000D76A8 /* Deployment */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - ppc, - i386, - ); - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; }; name = Deployment; }; 78E9AE1D0A36A8E3000D76A8 /* Default */ = { isa = XCBuildConfiguration; buildSettings = { - SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; }; name = Default; }; diff --git a/packaging/macosx/ScriptExec/main.c b/packaging/macosx/ScriptExec/main.c index f413d438a..e754057a9 100644 --- a/packaging/macosx/ScriptExec/main.c +++ b/packaging/macosx/ScriptExec/main.c @@ -6,6 +6,7 @@ With modifications by Aaron Voisine for gimp.app With modifications by Marianne gagnon for Wilber-loves-apple With modifications by Michael Wybrow for Inkscape.app + With modifications by ~suv for Inkscape.app This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,7 +40,12 @@ #pragma mark Includes // Apple stuff + +// Note: including Carbon prevents building the launcher app in x86_64 +// used for StandardAlert in RequestUserAttention(), +// RedFatalAlert() and X11FailedHandler() #include + #include #include #include @@ -83,15 +89,14 @@ static void *OpenDoc(void *arg); static OSErr ExecuteScript(char *script, pid_t *pid); static void GetParameters(void); -static char* GetScript(void); -static char* GetOpenDoc(void); +static unsigned char* GetScript(void); +static unsigned char* GetOpenDoc(void); OSErr LoadMenuBar(char *appName); -static OSStatus FSMakePath(FSSpec file, char *path, long maxPathSize); +static OSStatus FSMakePath(FSRef fileRef, unsigned char *path, long maxPathSize); static void RedFatalAlert(Str255 errorString, Str255 expStr); -static short DoesFileExist(char *path); -static OSStatus FixFCCache(void); +static short DoesFileExist(unsigned char *path); static OSErr AppQuitAEHandler(const AppleEvent *theAppleEvent, AppleEvent *reply, long refCon); @@ -109,7 +114,7 @@ static OSErr AppReopenAppAEHandler(const AppleEvent *theAppleEvent, static OSStatus CompileAppleScript(const void* text, long textLength, AEDesc *resultData); static OSStatus SimpleCompileAppleScript(const char* theScript); -static void runScript(); +static OSErr runScript(); /////////////////////////////////////// // Globals @@ -181,7 +186,7 @@ int main(int argc, char* argv[]) GetParameters(); //load data from files containing exec settings // compile "icon clicked" script so it's ready to execute - SimpleCompileAppleScript("tell application \"X11\" to activate"); + SimpleCompileAppleScript("tell application \"XQuartz\" to activate"); RunApplicationEventLoop(); //Run the event loop return 0; @@ -253,116 +258,6 @@ static OSStatus FCCacheFailedHandler(EventHandlerCallRef theHandlerCall, } -static size_t safeRead(int d, void *buf, size_t nbytes) -{ - ssize_t bytesToRead = nbytes; - ssize_t bytesRead = 0; - char *offset = (char *) buf; - - while ((bytesToRead > 0)) - { - bytesRead = read(d, offset, bytesToRead); - if (bytesRead > 0) - { - offset += bytesRead; - bytesToRead -= bytesRead; - } - else if (bytesRead == 0) - { - // Reached EOF. - break; - } - else if (bytesRead == -1) - { - if ((errno == EINTR) || (errno == EAGAIN)) - { - // Try again. - continue; - } - return 0; - } - } - return bytesRead; -} - - -///////////////////////////////////// -// Code to run fc-cache on first run -///////////////////////////////////// -static OSStatus FixFCCache (void) -{ - FILE *fileConnToChild = NULL; - int fdConnToChild = 0; - pid_t childPID = WAIT_ANY; - size_t bytesChildPID; - size_t bytesRead; - int status; - - char commandStr[] = "/usr/X11R6/bin/fc-cache"; - char *commandArgs[] = { "-f", NULL }; - - // Run fc-cache - AuthorizationItem authItems[] = - { - { - kAuthorizationRightExecute, - strlen(commandStr), - commandStr, - 0 - } - }; - AuthorizationItemSet authItemSet = - { - 1, - authItems - }; - AuthorizationRef authRef = NULL; - OSStatus err = AuthorizationCreate (NULL, &authItemSet, - kAuthorizationFlagInteractionAllowed | - kAuthorizationFlagExtendRights, &authRef); - - if (err == errAuthorizationSuccess) - { - err = AuthorizationExecuteWithPrivileges(authRef, commandStr, - kAuthorizationFlagDefaults, commandArgs, - &fileConnToChild); - - if (err == errAuthorizationSuccess) - { - // Unfortunately, AuthorizationExecuteWithPrivileges - // does not return the process ID associated with the - // process it runs. The best solution we have it to - // try and get the process ID from the file descriptor. - // This is based on example code from Apple's - // MoreAuthSample. - - fdConnToChild = fileno(fileConnToChild); - - // Try an get the process ID of the fc-cache command - bytesChildPID = sizeof(childPID); - bytesRead = safeRead(fdConnToChild, &childPID, - bytesChildPID); - if (bytesRead != bytesChildPID) - { - // If we can't get it the best alternative - // is to wait for any child to finish. - childPID = WAIT_ANY; - } - - if (fileConnToChild != NULL) { - fclose(fileConnToChild); - } - - // Wait for child process to finish. - waitpid(childPID, &status, 0); - } - } - AuthorizationFree(authRef, kAuthorizationFlagDestroyRights); - - return err; -} - - /////////////////////////////////// // Execution thread starts here /////////////////////////////////// @@ -448,14 +343,13 @@ static void GetParameters (void) /////////////////////////////////////// // Get path to the script in Resources folder /////////////////////////////////////// -static char* GetScript (void) +static unsigned char* GetScript (void) { CFStringRef fileName; CFBundleRef appBundle; CFURLRef scriptFileURL; FSRef fileRef; - FSSpec fileSpec; - char *path; + unsigned char *path; //get CF URL for script if (! (appBundle = CFBundleGetMainBundle())) return NULL; @@ -472,13 +366,9 @@ static char* GetScript (void) CFRelease(scriptFileURL); CFRelease(fileName); - //convert FSRef to FSSpec - if (FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec, - NULL)) return NULL; - //create path string if (! (path = malloc(kMaxPathLength))) return NULL; - if (FSMakePath(fileSpec, path, kMaxPathLength)) return NULL; + if (FSMakePath(fileRef, path, kMaxPathLength)) return NULL; if (! DoesFileExist(path)) return NULL; return path; @@ -487,14 +377,13 @@ static char* GetScript (void) /////////////////////////////////////// // Gets the path to openDoc in Resources folder /////////////////////////////////////// -static char* GetOpenDoc (void) +static unsigned char* GetOpenDoc (void) { CFStringRef fileName; CFBundleRef appBundle; CFURLRef openDocFileURL; FSRef fileRef; - FSSpec fileSpec; - char *path; + unsigned char *path; //get CF URL for openDoc if (! (appBundle = CFBundleGetMainBundle())) return NULL; @@ -511,13 +400,9 @@ static char* GetOpenDoc (void) CFRelease(openDocFileURL); CFRelease(fileName); - //convert FSRef to FSSpec - if (FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec, - NULL)) return NULL; - //create path string if (! (path = malloc(kMaxPathLength))) return NULL; - if (FSMakePath(fileSpec, path, kMaxPathLength)) return NULL; + if (FSMakePath(fileRef, path, kMaxPathLength)) return NULL; if (! DoesFileExist(path)) return NULL; return path; @@ -545,14 +430,8 @@ OSErr LoadMenuBar (char *appName) /////////////////////////////////////// // Generate path string from FSSpec record /////////////////////////////////////// -static OSStatus FSMakePath(FSSpec file, char *path, long maxPathSize) +static OSStatus FSMakePath(FSRef fileRef, unsigned char *path, long maxPathSize) { - OSErr err = noErr; - FSRef fileRef; - - //create file reference from file spec - if (err = FSpMakeFSRef(&file, &fileRef)) return err; - // and then convert the FSRef to a path return FSRefMakePath(&fileRef, path, maxPathSize); } @@ -569,9 +448,9 @@ static void RedFatalAlert (Str255 errorString, Str255 expStr) /////////////////////////////////////// // Determines whether file exists at path or not /////////////////////////////////////// -static short DoesFileExist (char *path) +static short DoesFileExist (unsigned char *path) { - if (access(path, F_OK) == -1) return false; + if (access((char *)path, F_OK) == -1) return false; return true; } @@ -590,7 +469,7 @@ static OSErr AppQuitAEHandler(const AppleEvent *theAppleEvent, if (! taskDone && pid) { //kill the script process brutally kill(pid, 9); - printf("Platypus App: PID %d killed brutally\n", pid); + printf("Inkscape.app: PID %d killed brutally\n", pid); } pthread_cancel(tid); @@ -610,31 +489,31 @@ static OSErr AppOpenDocAEHandler(const AppleEvent *theAppleEvent, #pragma unused (reply, refCon) OSErr err = noErr; - AEDescList fileSpecList; + AEDescList fileRefList; AEKeyword keyword; DescType type; short i; long count, actualSize; - FSSpec fileSpec; - char path[kMaxPathLength]; + FSRef fileRef; + unsigned char path[kMaxPathLength]; while (numArgs > 0) free(fileArgs[numArgs--]); //Read the AppleEvent err = AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList, - &fileSpecList); + &fileRefList); - err = AECountItems(&fileSpecList, &count); //Count number of files + err = AECountItems(&fileRefList, &count); //Count number of files for (i = 1; i <= count; i++) { //iteratively process each file - //get fsspec from apple event - if (! (err = AEGetNthPtr(&fileSpecList, i, typeFSS, &keyword, &type, - (Ptr)&fileSpec, sizeof(FSSpec), &actualSize))) + //get fsref from apple event + if (! (err = AEGetNthPtr(&fileRefList, i, typeFSRef, &keyword, &type, + (Ptr)&fileRef, sizeof(FSRef), &actualSize))) { - //get path from file spec - if ((err = FSMakePath(fileSpec, (unsigned char *)&path, + //get path from file ref + if ((err = FSMakePath(fileRef, (unsigned char *)&path, kMaxPathLength))) return err; if (numArgs == kMaxArgumentsToScript) break; @@ -659,7 +538,7 @@ static OSErr AppOpenDocAEHandler(const AppleEvent *theAppleEvent, static OSErr AppReopenAppAEHandler(const AppleEvent *theAppleEvent, AppleEvent *reply, long refCon) { - runScript(); + return runScript(); } // if app is being opened @@ -724,12 +603,12 @@ static OSStatus X11FailedHandler(EventHandlerCallRef theHandlerCall, params.position = kWindowDefaultPosition; StandardAlert(kAlertStopAlert, "\pFailed to start X11", - "\pInkscape.app requires Apple's X11, which is freely downloadable from Apple's website for Panther (10.3.x) users and available as an optional install from the installation DVD for Tiger (10.4.x) users.\n\nPlease install X11 and restart Inkscape.", + "\pInkscape.app requires XQuartz.", ¶ms, &itemHit); if (itemHit == kAlertStdAlertCancelButton) { - OpenURL("http://www.apple.com/downloads/macosx/apple/macosx_updates/x11formacosx.html"); + OpenURL("http://xquartz.macosforge.org/landing/"); } ExitToShell(); @@ -774,7 +653,7 @@ static OSStatus CompileAppleScript(const void* text, long textLength, } /* runs the compiled applescript */ -static void runScript() +static OSErr runScript() { /* run the script */ err = OSAExecute(theComponent, scriptID, kOSANullScript, -- cgit v1.2.3