From 28ecf70db57828db2ca279643bf9aeca7662f35c Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Wed, 19 Nov 2003 14:34:18 +0000 Subject: Getting rid of support for MacOS9 and earlier. This is the first step, and the biggest in size, but probably the easiest. Hunting through the source code comes next. --- Mac/Python/getapplbycreator.c | 163 ----------- Mac/Python/gusiconfig.cpp | 137 --------- Mac/Python/macapplication.c | 83 ------ Mac/Python/macgetargv.c | 247 ---------------- Mac/Python/macgetcompiler.c | 61 ---- Mac/Python/macgetpath.c | 442 ----------------------------- Mac/Python/macgetplatform.c | 39 --- Mac/Python/macglue.c | 617 ---------------------------------------- Mac/Python/macimport.c | 445 ----------------------------- Mac/Python/macmain.c | 640 ------------------------------------------ Mac/Python/macsetfiletype.c | 75 ----- Mac/Python/macshlglue.c | 128 --------- Mac/Python/pyGUSISIOUX.cp | 239 ---------------- 13 files changed, 3316 deletions(-) delete mode 100644 Mac/Python/getapplbycreator.c delete mode 100644 Mac/Python/gusiconfig.cpp delete mode 100644 Mac/Python/macapplication.c delete mode 100644 Mac/Python/macgetargv.c delete mode 100644 Mac/Python/macgetcompiler.c delete mode 100644 Mac/Python/macgetpath.c delete mode 100644 Mac/Python/macgetplatform.c delete mode 100644 Mac/Python/macglue.c delete mode 100644 Mac/Python/macimport.c delete mode 100644 Mac/Python/macmain.c delete mode 100644 Mac/Python/macsetfiletype.c delete mode 100644 Mac/Python/macshlglue.c delete mode 100644 Mac/Python/pyGUSISIOUX.cp (limited to 'Mac/Python') diff --git a/Mac/Python/getapplbycreator.c b/Mac/Python/getapplbycreator.c deleted file mode 100644 index 8c0b00fd93..0000000000 --- a/Mac/Python/getapplbycreator.c +++ /dev/null @@ -1,163 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI or Corporation for National Research Initiatives or -CNRI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -While CWI is the initial source for this software, a modified version -is made available by the Corporation for National Research Initiatives -(CNRI) at the Internet address ftp://ftp.python.org. - -STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH -CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* -** FindApplicationFromCreator uses the Desktop Database to -** locate the creator application for the given document -** -** this routine will check the desktop database of all local -** disks, then the desktop databases of all server volumes -** (so up to two passes will be made) -** -** This code was created from FindApplicationFromDocument -** routine, origin unknown. -*/ - -#ifdef WITHOUT_FRAMEWORKS -#include -#include -#include -#else -#include -#endif -#include "getapplbycreator.h" - - -OSErr FindApplicationFromCreator(OSType creator, - FSSpecPtr applicationFSSpecPtr) -{ - enum { localPass, remotePass, donePass } volumePass; - DTPBRec desktopParams; - HParamBlockRec hfsParams; - short volumeIndex; - Boolean foundFlag; - GetVolParmsInfoBuffer volumeInfoBuffer; - OSErr retCode; - -/* dkj 12/94 initialize flag to false (thanks to Peter Baral for pointing out this bug) */ - foundFlag = false; - - volumePass = localPass; - volumeIndex = 0; - - do { - /* - ** first, find the vRefNum of the volume whose Desktop Database - ** we're checking this time - */ - - volumeIndex++; - - /* convert the volumeIndex into a vRefNum */ - - hfsParams.volumeParam.ioNamePtr = nil; - hfsParams.volumeParam.ioVRefNum = 0; - hfsParams.volumeParam.ioVolIndex = volumeIndex; - retCode = PBHGetVInfoSync(&hfsParams); - - /* a nsvErr indicates that the current pass is over */ - if (retCode == nsvErr) goto SkipThisVolume; - if (retCode != noErr) goto Bail; - - /* - ** call GetVolParms to determine if this volume is a server - ** (a remote volume) - */ - - hfsParams.ioParam.ioBuffer = (Ptr) &volumeInfoBuffer; - hfsParams.ioParam.ioReqCount = sizeof(GetVolParmsInfoBuffer); - retCode = PBHGetVolParmsSync(&hfsParams); - if (retCode != noErr) goto Bail; - - /* - ** if the vMServerAdr field of the volume information buffer - ** is zero, this is a local volume; skip this volume - ** if it's local on a remote pass or remote on a local pass - */ - - if ((volumeInfoBuffer.vMServerAdr != 0) != - (volumePass == remotePass)) goto SkipThisVolume; - - /* okay, now we've found the vRefNum for our desktop database call */ - - desktopParams.ioVRefNum = hfsParams.volumeParam.ioVRefNum; - - /* - ** find the path refNum for the desktop database for - ** the volume we're interested in - */ - - desktopParams.ioNamePtr = nil; - - retCode = PBDTGetPath(&desktopParams); - if (retCode == noErr && desktopParams.ioDTRefNum != 0) { - - /* - ** use the GetAPPL call to find the preferred application - ** for opening any document with this one's creator - */ - - desktopParams.ioIndex = 0; - desktopParams.ioFileCreator = creator; - desktopParams.ioNamePtr = applicationFSSpecPtr->name; - retCode = PBDTGetAPPLSync(&desktopParams); - - if (retCode == noErr) { - /* - ** okay, found it; fill in the application file spec - ** and set the flag indicating we're done - */ - - applicationFSSpecPtr->parID = desktopParams.ioAPPLParID; - applicationFSSpecPtr->vRefNum = desktopParams.ioVRefNum; - foundFlag = true; - - } - } - - SkipThisVolume: - /* - ** if retCode indicates a no such volume error or if this - ** was the first pass, it's time to move on to the next pass - */ - - if (retCode == nsvErr) { - volumePass++; - volumeIndex = 0; - } - - } while (foundFlag == false && volumePass != donePass); - -Bail: - if (retCode == nsvErr) - return fnfErr; /* More logical than "No such volume" */ - return retCode; -} diff --git a/Mac/Python/gusiconfig.cpp b/Mac/Python/gusiconfig.cpp deleted file mode 100644 index ec6b57d578..0000000000 --- a/Mac/Python/gusiconfig.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Generated with the GUSIConfig application and then hand-modified by jack. - */ - -#define GUSI_SOURCE -#include -#include -#include - -#include "Python.h" -#include "macglue.h" -#include "pythonresources.h" - -static void -PyMac_GUSISpin(bool wait) -{ - static Boolean inForeground = true; - int maxsleep = 6; /* 6 ticks is "normal" sleeptime */ - - if (PyMac_ConsoleIsDead) return; - - if ( !wait ) - maxsleep = 0; - - PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */ -} - - -/* Declarations of Socket Factories */ - -__BEGIN_DECLS -void GUSIwithInetSockets(); -void GUSIwithLocalSockets(); -void GUSIwithMTInetSockets(); -void GUSIwithMTTcpSockets(); -void GUSIwithMTUdpSockets(); -void GUSIwithOTInetSockets(); -void GUSIwithOTTcpSockets(); -void GUSIwithOTUdpSockets(); -void GUSIwithPPCSockets(); -void GUSISetupFactories(); -__END_DECLS - -/* Configure Socket Factories */ - -void GUSISetupFactories() -{ -#ifdef GUSISetupFactories_BeginHook - GUSISetupFactories_BeginHook -#endif - GUSIwithInetSockets(); -#ifdef GUSISetupFactories_EndHook - GUSISetupFactories_EndHook -#endif -} - -/* Declarations of File Devices */ - -__BEGIN_DECLS -void GUSIwithDConSockets(); -void GUSIwithNullSockets(); -void GUSISetupDevices(); -__END_DECLS - -/* Configure File Devices */ - -void GUSISetupDevices() -{ -#ifdef GUSISetupDevices_BeginHook - GUSISetupDevices_BeginHook -#endif -#ifdef GUSISetupDevices_EndHook - GUSISetupDevices_EndHook -#endif -} - -#ifndef __cplusplus -#error GUSISetupConfig() needs to be written in C++ -#endif - -GUSIConfiguration::FileSuffix sSuffices[] = { - "", '????', '????' -}; -extern "C" void GUSISetupConfig() -{ - Handle h; - short oldrh, prefrh = -1; - short resource_id = GUSIConfiguration::kNoResource; - - oldrh = CurResFile(); - - /* Try override from the application resource fork */ - UseResFile(PyMac_AppRefNum); - h = Get1Resource('GU\267I', GUSIOPTIONSOVERRIDE_ID); - if ( h ) { - resource_id = GUSIOPTIONSOVERRIDE_ID; - } else { - /* Next try normal resource from preference file */ - UseResFile(oldrh); - prefrh = PyMac_OpenPrefFile(); - h = Get1Resource('GU\267I', GUSIOPTIONS_ID); - if ( h ) { - resource_id = GUSIOPTIONS_ID; - } else { - /* Finally try normal resource from application */ - if ( prefrh != -1 ) { - CloseResFile(prefrh); - prefrh = -1; - } - resource_id = GUSIOPTIONS_ID; - } - } - - /* Now we have the right resource file topmost and the id. Init GUSI. */ - GUSIConfiguration * config = - GUSIConfiguration::CreateInstance(resource_id); - - /* Finally restore the old resource file */ - if ( prefrh != -1) CloseResFile(prefrh); - UseResFile(oldrh); - - config->ConfigureDefaultTypeCreator('TEXT', 'R*ch'); -#if 0 - config->ConfigureSuffices( - sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices); -#endif - config->ConfigureAutoInitGraf(false); - config->ConfigureAutoSpin(false); - config->ConfigureHandleAppleEvents(false); - config->ConfigureSigInt(false); - config->ConfigureSigPipe(true); - - GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin); - -} - -/**************** END GUSI CONFIGURATION *************************/ diff --git a/Mac/Python/macapplication.c b/Mac/Python/macapplication.c deleted file mode 100644 index 4c71234637..0000000000 --- a/Mac/Python/macapplication.c +++ /dev/null @@ -1,83 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Macintosh Python main program for both applets and interpreter */ - -#include -#include - -extern void PyMac_InitApplication(void); -#ifdef USE_MAC_APPLET_SUPPORT -extern void PyMac_InitApplet(void); -#endif /* USE_MAC_APPLET_SUPPORT */ - -/* From the MSL runtime: */ -extern void __initialize(void); - -/* -** Alternative initialization entry point for some very special cases. -** Use this in stead of __initialize in the PEF settings to remember (and -** re-open as resource file) the application. This is needed if we link against -** a dynamic library that, in its own __initialize routine, opens a resource -** file. This would mess up our finding of override preferences. -** Only set this entrypoint in your apps if you notice sys.path or some such is -** messed up. -*/ -static int application_fss_valid; -static FSSpec application_fss; - -OSErr pascal -__initialize_remember_app_fsspec(CFragInitBlockPtr data) -{ - /* Call the MW runtime's initialization routine */ - __initialize(); - if ( data == nil ) return noErr; - if ( data->fragLocator.where == kDataForkCFragLocator ) { - application_fss = *data->fragLocator.u.onDisk.fileSpec; - application_fss_valid = 1; - } else if ( data->fragLocator.where == kResourceCFragLocator ) { - application_fss = *data->fragLocator.u.inSegs.fileSpec; - application_fss_valid = 1; - } - return noErr; -} - -void -main() { - if ( application_fss_valid ) - (void)FSpOpenResFile(&application_fss, fsRdPerm); -#ifdef USE_MAC_APPLET_SUPPORT - { - Handle mainpyc; - - mainpyc = Get1NamedResource('PYC ', "\p__main__"); - if (mainpyc != NULL) - PyMac_InitApplet(); - else - PyMac_InitApplication(); - } -#else - PyMac_InitApplication(); -#endif /* USE_MAC_APPLET_SUPPORT */ -} diff --git a/Mac/Python/macgetargv.c b/Mac/Python/macgetargv.c deleted file mode 100644 index f301bab074..0000000000 --- a/Mac/Python/macgetargv.c +++ /dev/null @@ -1,247 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Construct argc and argv for main() by using Apple Events */ -/* From Jack's implementation for STDWIN */ - -#include - -#ifdef WITHOUT_FRAMEWORKS -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#else -#include -#endif /* WITHOUT_FRAMEWORKS */ - -typedef long refcontype; - -#include "Python.h" -#include "macglue.h" - -#define PATHNAMELEN 256 - -static int arg_count; -static char *arg_vector[256]; -FSSpec PyMac_ApplicationFSSpec; -char PyMac_ApplicationPath[PATHNAMELEN]; - -/* Duplicate a string to the heap. We also export this since it isn't standard -** and others use it -*/ -#ifndef HAVE_STRDUP -char * -strdup(const char *src) -{ - char *dst = malloc(strlen(src) + 1); - if (dst) - strcpy(dst, src); - return dst; -} -#endif - -/* Initialize FSSpec and full name of current application */ - -OSErr -PyMac_init_process_location(void) -{ - ProcessSerialNumber currentPSN; - ProcessInfoRec info; - OSErr err; - static int applocation_inited; - - if ( applocation_inited ) return 0; - currentPSN.highLongOfPSN = 0; - currentPSN.lowLongOfPSN = kCurrentProcess; - info.processInfoLength = sizeof(ProcessInfoRec); - info.processName = NULL; - info.processAppSpec = &PyMac_ApplicationFSSpec; - if ( err=GetProcessInformation(¤tPSN, &info)) - return err; - if ( err=PyMac_GetFullPathname(&PyMac_ApplicationFSSpec, PyMac_ApplicationPath, PATHNAMELEN) ) - return err; - applocation_inited = 1; - return 0; -} - -/* Check that there aren't any args remaining in the event */ - -static OSErr -get_missing_params(const AppleEvent *theAppleEvent) -{ - DescType theType; - Size actualSize; - OSErr err; - - err = AEGetAttributePtr(theAppleEvent, keyMissedKeywordAttr, typeWildCard, - &theType, nil, 0, &actualSize); - if (err == errAEDescNotFound) - return noErr; - else - return errAEEventNotHandled; -} - -static int got_one; /* Flag that we can stop getting events */ - -/* Handle the Print or Quit events (by failing) */ - -static pascal OSErr -handle_not(const AppleEvent *theAppleEvent, AppleEvent *reply, refcontype refCon) -{ - #pragma unused (reply, refCon) - got_one = 1; - return errAEEventNotHandled; -} - -/* Handle the Open Application event (by ignoring it) */ - -static pascal OSErr -handle_open_app(const AppleEvent *theAppleEvent, AppleEvent *reply, refcontype refCon) -{ - #pragma unused (reply, refCon) -#if 0 - /* Test by Jack: would removing this facilitate debugging? */ - got_one = 1; -#endif - return get_missing_params(theAppleEvent); -} - -/* Handle the Open Document event, by adding an argument */ - -static pascal OSErr -handle_open_doc(const AppleEvent *theAppleEvent, AppleEvent *reply, refcontype refCon) -{ - #pragma unused (reply, refCon) - OSErr err; - AEDescList doclist; - AEKeyword keywd; - DescType rttype; - long i, ndocs, size; - FSSpec fss; - char path[PATHNAMELEN]; - - got_one = 1; - if ((err = AEGetParamDesc(theAppleEvent, - keyDirectObject, typeAEList, &doclist))) - return err; - if ((err = get_missing_params(theAppleEvent))) - return err; - if ((err = AECountItems(&doclist, &ndocs))) - return err; - for(i = 1; i <= ndocs; i++) { - err = AEGetNthPtr(&doclist, i, typeFSS, - &keywd, &rttype, &fss, sizeof(fss), &size); - if (err) - break; - PyMac_GetFullPathname(&fss, path, PATHNAMELEN); - arg_vector[arg_count++] = strdup(path); - } - return err; -} - -/* Install standard core event handlers */ -AEEventHandlerUPP open_doc_upp; -AEEventHandlerUPP open_app_upp; -AEEventHandlerUPP not_upp; - -static void -set_ae_handlers(void) -{ - open_doc_upp = NewAEEventHandlerUPP(&handle_open_doc); - open_app_upp = NewAEEventHandlerUPP(&handle_open_app); - not_upp = NewAEEventHandlerUPP(&handle_not); - - AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, - open_app_upp, 0L, false); - AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, - open_doc_upp, 0L, false); - AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, - not_upp, 0L, false); - AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, - not_upp, 0L, false); -} - -/* Uninstall standard core event handlers */ - -static void -reset_ae_handlers(void) -{ - AERemoveEventHandler(kCoreEventClass, kAEOpenApplication, - open_app_upp, false); - AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments, - open_doc_upp, false); - AERemoveEventHandler(kCoreEventClass, kAEPrintDocuments, - not_upp, false); - AERemoveEventHandler(kCoreEventClass, kAEQuitApplication, - not_upp, false); -} - -/* Wait for events until a core event has been handled */ - -static void -event_loop(void) -{ - EventRecord event; - int n; - int ok; - - got_one = 0; - for (n = 0; n < 100 && !got_one; n++) { - ok = GetNextEvent(everyEvent, &event); - if (ok && event.what == kHighLevelEvent) { - AEProcessAppleEvent(&event); - } - } -} - -/* Get the argv vector, return argc */ - -int -PyMac_GetArgv(char ***pargv, int noevents) -{ - arg_count = 0; - (void)PyMac_init_process_location(); - arg_vector[arg_count++] = strdup(PyMac_ApplicationPath); - - if( !noevents ) { - set_ae_handlers(); - event_loop(); - reset_ae_handlers(); - } - - arg_vector[arg_count] = NULL; - - *pargv = arg_vector; - return arg_count; -} diff --git a/Mac/Python/macgetcompiler.c b/Mac/Python/macgetcompiler.c deleted file mode 100644 index b5da2bf6dc..0000000000 --- a/Mac/Python/macgetcompiler.c +++ /dev/null @@ -1,61 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI or Corporation for National Research Initiatives or -CNRI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -While CWI is the initial source for this software, a modified version -is made available by the Corporation for National Research Initiatives -(CNRI) at the Internet address ftp://ftp.python.org. - -STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH -CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Return a string representing the compiler name */ - -#include "pyconfig.h" -#include "Python.h" - -#ifdef __MWERKS__ -#ifdef USE_GUSI2 -#define HASGUSI "" -#else -#define HASGUSI " WITHOUT_GUSI2" -#endif - -#ifdef WITH_THREAD -#define HASTHREAD "" -#else -#define HASTHREAD " WITHOUT_THREAD" -#endif - -#define COMPILER " [CW" HASGUSI HASTHREAD"]" -#endif - -#ifdef MPW -#define COMPILER " [Apple MPW]" -#endif - -const char * -Py_GetCompiler(void) -{ - return COMPILER; -} diff --git a/Mac/Python/macgetpath.c b/Mac/Python/macgetpath.c deleted file mode 100644 index d98d481206..0000000000 --- a/Mac/Python/macgetpath.c +++ /dev/null @@ -1,442 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI or Corporation for National Research Initiatives or -CNRI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -While CWI is the initial source for this software, a modified version -is made available by the Corporation for National Research Initiatives -(CNRI) at the Internet address ftp://ftp.python.org. - -STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH -CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -#include "Python.h" -#include "osdefs.h" -#include "macglue.h" -#include "macdefs.h" -#include "pythonresources.h" -#ifdef HAVE_UNISTD_H -#include -#endif - -#define PATHNAMELEN 256 - -/* Return the initial python search path. This is called once from -** initsys() to initialize sys.path. -** -** If USE_BUILTIN_PATH is defined the path defined here is used -** (after prepending the python home dir to each item). -** If it is not defined the path is gotten from a resource in the -** Preferences file. -** -** XXXX This code needs cleaning up. The routines here have moved -** around quite a bit, and they're pretty messy for that reason. -*/ - -#include -#include -#include -#include -#include -#include - -#ifndef USE_BUILTIN_PATH -static char *PyMac_GetPythonPath(); -#endif - -#define PYTHONPATH "\ -:\n\ -:Lib\n\ -:Lib:stdwin\n\ -:Lib:test\n\ -:Lib:mac" - -static int -getpreffilefss(FSSpec *fssp) -{ - static int diditbefore=0; - static int rv = 1; - static FSSpec fss; - short prefdirRefNum; - long prefdirDirID; - long pyprefdirDirID; - Handle namehandle; - OSErr err; - - if ( !diditbefore ) { - if ( (namehandle=GetNamedResource('STR ', PREFFILENAME_NAME)) == NULL ) { - (void)StopAlert(NOPREFNAME_ID, NULL); - exit(1); - } - - if ( **namehandle == '\0' ) { - /* Empty string means don't use preferences file */ - rv = 0; - } else { - /* There is a filename, construct the fsspec */ - if ( FindFolder(kOnSystemDisk, 'pref', kDontCreateFolder, &prefdirRefNum, - &prefdirDirID) != noErr ) { - /* Something wrong with preferences folder */ - (void)StopAlert(NOPREFDIR_ID, NULL); - exit(1); - } - /* make fsspec for the "Python" folder inside the prefs folder */ - err = FSMakeFSSpec(prefdirRefNum, prefdirDirID, "\pPython", &fss); - if (err == fnfErr) { - /* it doesn't exist: create it */ - err = FSpDirCreate(&fss, smSystemScript, &pyprefdirDirID); - } else { - /* it does exist, now find out the dirID of the Python prefs folder, brrr. */ - CInfoPBRec info; - info.dirInfo.ioVRefNum = fss.vRefNum; - info.dirInfo.ioDrDirID = fss.parID; - info.dirInfo.ioNamePtr = fss.name; - info.dirInfo.ioFDirIndex = 0; - info.dirInfo.ioACUser = 0; - err = PBGetCatInfo(&info, 0); - if (err == noErr) { - pyprefdirDirID = info.dirInfo.ioDrDirID; - } - } - if (err != noErr) { - (void)StopAlert(NOPREFDIR_ID, NULL); - exit(1); - } - HLock(namehandle); - err = FSMakeFSSpec(fss.vRefNum, pyprefdirDirID, (unsigned char *)*namehandle, &fss); - HUnlock(namehandle); - if (err != noErr && err != fnfErr) { - (void)StopAlert(NOPREFDIR_ID, NULL); - exit(1); - } - } - ReleaseResource(namehandle); - diditbefore = 1; - } - *fssp = fss; - return rv; -} - -char * -Py_GetPath() -{ - /* Modified by Jack to do something a bit more sensible: - ** - Prepend the python home-directory (which is obtained from a Preferences - ** resource) - ** - Add : - */ - static char *pythonpath; - char *p, *endp; - int newlen; - char *curwd; - - if ( pythonpath ) return pythonpath; -#ifndef USE_BUILTIN_PATH - if ( pythonpath = PyMac_GetPythonPath() ) - return pythonpath; - printf("Warning: No pythonpath resource found, using builtin default\n"); -#endif - curwd = PyMac_GetPythonDir(); - p = PYTHONPATH; - endp = p; - pythonpath = malloc(2); - if ( pythonpath == NULL ) return PYTHONPATH; - strcpy(pythonpath, ":"); - while (*endp) { - endp = strchr(p, '\n'); - if ( endp == NULL ) - endp = p + strlen(p); - newlen = strlen(pythonpath) + 1 + strlen(curwd) + (endp-p); - pythonpath = realloc(pythonpath, newlen+1); - if ( pythonpath == NULL ) return PYTHONPATH; - strcat(pythonpath, "\n"); - if ( *p == ':' ) { - p++; - strcat(pythonpath, curwd); - strncat(pythonpath, p, (endp-p)); - newlen--; /* Ok, ok, we've allocated one byte too much */ - } else { - /* We've allocated too much in this case */ - newlen -= strlen(curwd); - pythonpath = realloc(pythonpath, newlen+1); - if ( pythonpath == NULL ) return PYTHONPATH; - strncat(pythonpath, p, (endp-p)); - } - pythonpath[newlen] = '\0'; - p = endp + 1; - } - return pythonpath; -} - - -/* -** Open/create the Python Preferences file, return the handle -*/ -short -PyMac_OpenPrefFile() -{ - AliasHandle handle; - FSSpec dirspec; - short prefrh; - OSErr err; - - if ( !getpreffilefss(&dirspec)) - return -1; - prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm); - if ( prefrh < 0 ) { - FSpCreateResFile(&dirspec, 'Pyth', 'pref', 0); - prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm); - if ( prefrh == -1 ) { - /* This "cannot happen":-) */ - printf("Cannot create preferences file, error %d\n", ResError()); - exit(1); - } - if ( (err=PyMac_init_process_location()) != 0 ) { - printf("Cannot get application location, error %d\n", err); - exit(1); - } - dirspec = PyMac_ApplicationFSSpec; - dirspec.name[0] = 0; - if ((err=NewAlias(NULL, &dirspec, &handle)) != 0 ) { - printf("Cannot make alias to application directory, error %d\n", err); - exit(1); - } - AddResource((Handle)handle, 'alis', PYTHONHOME_ID, "\p"); - UpdateResFile(prefrh); - - } else { - UseResFile(prefrh); - } - return prefrh; -} - -/* -** Return the name of the Python directory -*/ -char * -PyMac_GetPythonDir() -{ - static int diditbefore = 0; - static char name[PATHNAMELEN] = {':', '\0'}; - AliasHandle handle; - FSSpec dirspec; - Boolean modified = 0; - short oldrh, prefrh = -1, homerh; - - if ( diditbefore ) - return name; - - oldrh = CurResFile(); - - /* First look for an override in the application file */ - UseResFile(PyMac_AppRefNum); - handle = (AliasHandle)Get1Resource('alis', PYTHONHOMEOVERRIDE_ID); - UseResFile(oldrh); - if ( handle != NULL ) { - homerh = PyMac_AppRefNum; - } else { - /* Try to open preferences file in the preferences folder. */ - prefrh = PyMac_OpenPrefFile(); - handle = (AliasHandle)Get1Resource('alis', PYTHONHOME_ID); - if ( handle == NULL ) { - /* (void)StopAlert(BADPREFFILE_ID, NULL); */ - diditbefore=1; - return ":"; - } - homerh = prefrh; - } - /* It exists. Resolve it (possibly updating it) */ - if ( ResolveAlias(NULL, handle, &dirspec, &modified) != noErr ) { - (void)StopAlert(BADPREFFILE_ID, NULL); - diditbefore=1; - return ":"; - } - if ( modified ) { - ChangedResource((Handle)handle); - UpdateResFile(homerh); - } - if ( prefrh != -1 ) CloseResFile(prefrh); - UseResFile(oldrh); - - if ( PyMac_GetFullPathname(&dirspec, name, PATHNAMELEN) == 0 ) { - strcat(name, ":"); - } else { - /* If all fails, we return the current directory */ - printf("Python home dir exists but I cannot find the pathname!!\n"); - name[0] = 0; - (void)getcwd(name, sizeof(name)); - } - diditbefore = 1; - return name; -} - -#ifndef USE_BUILTIN_PATH -char * -PyMac_GetPythonPath(void) -{ - short oldrh, prefrh = -1; - char *rv; - int i, newlen; - Str255 pathitem; - int resource_id; - OSErr err; - Handle h; - - oldrh = CurResFile(); - /* - ** This is a bit tricky. We check here whether the application file - ** contains an override. This is to forestall us finding another STR# resource - ** with "our" id and using that for path initialization - */ - UseResFile(PyMac_AppRefNum); - SetResLoad(0); - if ( (h=Get1Resource('STR#', PYTHONPATHOVERRIDE_ID)) ) { - ReleaseResource(h); - resource_id = PYTHONPATHOVERRIDE_ID; - } else { - resource_id = PYTHONPATH_ID; - } - SetResLoad(1); - UseResFile(oldrh); - - /* Open the preferences file only if there is no override */ - if ( resource_id != PYTHONPATHOVERRIDE_ID ) - prefrh = PyMac_OpenPrefFile(); - /* At this point, we may or may not have the preferences file open, and it - ** may or may not contain a sys.path STR# resource. We don't care, if it doesn't - ** exist we use the one from the application (the default). - ** We put an initial '\n' in front of the path that we don't return to the caller - */ - if( (rv = malloc(2)) == NULL ) - goto out; - strcpy(rv, "\n"); - - for(i=1; ; i++) { - GetIndString(pathitem, resource_id, i); - if( pathitem[0] == 0 ) - break; - if ( pathitem[0] >= 9 && strncmp((char *)pathitem+1, "$(PYTHON)", 9) == 0 ) { - /* We have to put the directory in place */ - char *dir = PyMac_GetPythonDir(); - - newlen = strlen(rv) + strlen(dir) + (pathitem[0]-9) + 2; - if( (rv=realloc(rv, newlen)) == NULL) - goto out; - strcat(rv, dir); - /* Skip a colon at the beginning of the item */ - if ( pathitem[0] > 9 && pathitem[1+9] == ':' ) { - memcpy(rv+strlen(rv), pathitem+1+10, pathitem[0]-10); - newlen--; - } else { - memcpy(rv+strlen(rv), pathitem+1+9, pathitem[0]-9); - } - rv[newlen-2] = '\n'; - rv[newlen-1] = 0; - } else if ( pathitem[0] >= 14 && strncmp((char *)pathitem+1, "$(APPLICATION)", 14) == 0 ) { - /* This is the application itself */ - - if ( (err=PyMac_init_process_location()) != 0 ) { - printf("Cannot get application location, error %d\n", err); - exit(1); - } - - newlen = strlen(rv) + strlen(PyMac_ApplicationPath) + 2; - if( (rv=realloc(rv, newlen)) == NULL) - goto out; - strcpy(rv+strlen(rv), PyMac_ApplicationPath); - rv[newlen-2] = '\n'; - rv[newlen-1] = 0; - - } else { - /* Use as-is */ - newlen = strlen(rv) + (pathitem[0]) + 2; - if( (rv=realloc(rv, newlen)) == NULL) - goto out; - memcpy(rv+strlen(rv), pathitem+1, pathitem[0]); - rv[newlen-2] = '\n'; - rv[newlen-1] = 0; - } - } - if( strlen(rv) == 1) { - free(rv); - rv = NULL; - } - if ( rv ) { - rv[strlen(rv)-1] = 0; - rv++; - } -out: - if ( prefrh != -1) CloseResFile(prefrh); - UseResFile(oldrh); - return rv; -} -#endif /* !USE_BUILTIN_PATH */ - -void -PyMac_PreferenceOptions(PyMac_PrefRecord *pr) -{ - short oldrh, prefrh = -1; - Handle handle; - int size; - PyMac_PrefRecord *p; - int action; - - - oldrh = CurResFile(); - - /* Attempt to load overrides from application */ - UseResFile(PyMac_AppRefNum); - handle = Get1Resource('Popt', PYTHONOPTIONSOVERRIDE_ID); - UseResFile(oldrh); - - /* Otherwise get options from prefs file or any other open resource file */ - if ( handle == NULL ) { - prefrh = PyMac_OpenPrefFile(); - handle = GetResource('Popt', PYTHONOPTIONS_ID); - } - if ( handle == NULL ) { - return; - } - HLock(handle); - size = GetHandleSize(handle); - p = (PyMac_PrefRecord *)*handle; - if ( p->version == POPT_VERSION_CURRENT && size == sizeof(PyMac_PrefRecord) ) { - *pr = *p; - } else { - action = CautionAlert(BADPREFERENCES_ID, NULL); - if ( action == BADPREF_DELETE ) { - OSErr err; - - RemoveResource(handle); - if ( (err=ResError()) ) printf("RemoveResource: %d\n", err); - if ( prefrh != -1 ) { - UpdateResFile(prefrh); - if ( (err=ResError()) ) printf("UpdateResFile: %d\n", err); - } - } else if ( action == BADPREF_QUIT ) - exit(1); - } - HUnlock(handle); - - if ( prefrh != -1) CloseResFile(prefrh); - UseResFile(oldrh); -} diff --git a/Mac/Python/macgetplatform.c b/Mac/Python/macgetplatform.c deleted file mode 100644 index 3640d760ee..0000000000 --- a/Mac/Python/macgetplatform.c +++ /dev/null @@ -1,39 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI or Corporation for National Research Initiatives or -CNRI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -While CWI is the initial source for this software, a modified version -is made available by the Corporation for National Research Initiatives -(CNRI) at the Internet address ftp://ftp.python.org. - -STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH -CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -#include "Python.h" - -const char * -Py_GetPlatform(void) -{ - return "mac"; -} - diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c deleted file mode 100644 index 371161020e..0000000000 --- a/Mac/Python/macglue.c +++ /dev/null @@ -1,617 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - - -#include "Python.h" - -#include "macglue.h" -#include "marshal.h" -#include "import.h" -#include "importdl.h" -#include "pymactoolbox.h" - -#include "pythonresources.h" - -#ifdef WITHOUT_FRAMEWORKS -#include /* for Set(Current)A5 */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#else -#include -#endif - -#ifdef __MWERKS__ -#include -extern void SIOUXSetupMenus(void); -extern void SIOUXDoAboutBox(void); -#endif -#ifdef USE_GUSI -/* Functions we redefine because they're in obscure libraries */ -extern void SpinCursor(short x); -extern void RotateCursor(short x); -extern pascal unsigned char * PLstrcpy(unsigned char *, const unsigned char *); -extern pascal short PLstrcmp(const unsigned char *, const unsigned char *); -extern pascal char *PLstrrchr(const unsigned char *, short); - -#endif - -/* The ID of the Sioux apple menu */ -#define SIOUX_APPLEID 32000 - -#include -#include - -/* -** When less than this amount of stackspace is left we -** raise a MemoryError. -*/ -#ifndef MINIMUM_STACK_SIZE -#define MINIMUM_STACK_SIZE 8192 -#endif - -/* -** On MacOSX StackSpace() lies: it gives the distance from heap end to stack pointer, -** but the stack cannot grow that far due to rlimit values. We cannot get at this value -** from Carbon, so we set a maximum to the stack here that is based on the default -** stack limit of 512K. -*/ -#define MAXIMUM_STACK_SIZE (256*1024) - -/* -** We have to be careful, since we can't handle -** things like updates (and they'll keep coming back if we don't -** handle them). Note that we don't know who has windows open, so -** even handing updates off to SIOUX under MW isn't going to work. -*/ -#define MAINLOOP_EVENTMASK (mDownMask|keyDownMask|osMask|activMask) - -#include - -/* XXX We should include Errors.h here, but it has a name conflict -** with the python errors.h. */ -#define fnfErr -43 - -/* Interrupt code variables: */ -static int interrupted; /* Set to true when cmd-. seen */ -static RETSIGTYPE intcatcher(int); - -#if !TARGET_API_MAC_OSX -static int PyMac_Yield(void); -#endif - -/* -** These are the real scheduling parameters that control what we check -** in the event loop, and how often we check. The values are initialized -** from pyMac_SchedParamStruct. -*/ - -struct real_sched_param_struct { - int check_interrupt; /* if true check for command-dot */ - int process_events; /* if nonzero enable evt processing, this mask */ - int besocial; /* if nonzero be a little social with CPU */ - unsigned long check_interval; /* how often to check, in ticks */ - unsigned long bg_yield; /* yield so long when in background */ - /* these are computed from previous and clock and such */ - int enabled; /* check_interrupt OR process_event OR yield */ - unsigned long next_check; /* when to check/yield next, in ticks */ -}; - -static struct real_sched_param_struct schedparams = - { 1, MAINLOOP_EVENTMASK, 1, 15, 15, 1, 0}; - -/* -** Workaround for sioux/gusi combo: set when we are exiting -*/ -int PyMac_ConsoleIsDead; - -/* -** Sioux menu bar, saved early so we can restore it -*/ -static MenuBarHandle sioux_mbar; - -/* -** The python-code event handler -*/ -static PyObject *python_event_handler; - -/* Given an FSSpec, return the FSSpec of the parent folder */ - -static OSErr -get_folder_parent (FSSpec * fss, FSSpec * parent) -{ - CInfoPBRec rec; - short err; - - * parent = * fss; - rec.hFileInfo.ioNamePtr = parent->name; - rec.hFileInfo.ioVRefNum = parent->vRefNum; - rec.hFileInfo.ioDirID = parent->parID; - rec.hFileInfo.ioFDirIndex = -1; - rec.hFileInfo.ioFVersNum = 0; - if (err = PBGetCatInfoSync (& rec)) - return err; - parent->parID = rec.dirInfo.ioDrParID; -/* parent->name[0] = 0; */ - return 0; -} - -/* Given an FSSpec return a full, colon-separated pathname */ - -OSErr -PyMac_GetFullPathname (FSSpec *fss, char *buf, int length) -{ - short err; - FSSpec fss_parent, fss_current; - char tmpbuf[1024]; - int plen; - - fss_current = *fss; - plen = fss_current.name[0]; - if ( plen+2 > length ) { - *buf = 0; - return errFSNameTooLong; - } - memcpy(buf, &fss_current.name[1], plen); - buf[plen] = 0; - /* Special case for disk names */ - if ( fss_current.parID <= 1 ) { - buf[plen++] = ':'; - buf[plen] = 0; - return 0; - } - while (fss_current.parID > 1) { - /* Get parent folder name */ - if (err = get_folder_parent(&fss_current, &fss_parent)) { - *buf = 0; - return err; - } - fss_current = fss_parent; - /* Prepend path component just found to buf */ - plen = fss_current.name[0]; - if (strlen(buf) + plen + 1 > 1024) { - /* Oops... Not enough space (shouldn't happen) */ - *buf = 0; - return errFSNameTooLong; - } - memcpy(tmpbuf, &fss_current.name[1], plen); - tmpbuf[plen] = ':'; - strcpy(&tmpbuf[plen+1], buf); - if ( strlen(tmpbuf) > length ) { - *buf = 0; - return errFSNameTooLong; - } - strcpy(buf, tmpbuf); - } - return 0; -} - - -#ifdef USE_GUSI -/* -** SpinCursor (needed by GUSI) drags in heaps of stuff, so we -** provide a dummy here. -*/ -void SpinCursor(short x) { /* Dummy */ } -void RotateCursor(short x) { /* Dummy */ } - - -/* Called at exit() time thru atexit(), to stop event processing */ -void -PyMac_StopGUSISpin() { - PyMac_ConsoleIsDead = 1; -} - -#endif /* USE_GUSI */ - - -/* Convert C to Pascal string. Returns pointer to static buffer. */ -unsigned char * -Pstring(char *str) -{ - static Str255 buf; - int len; - - len = strlen(str); - if (len > 255) - len = 255; - buf[0] = (unsigned char)len; - strncpy((char *)buf+1, str, len); - return buf; -} - - -#ifdef USE_STACKCHECK -/* Check for stack overflow */ -int -PyOS_CheckStack() -{ - char here; - static char *sentinel = 0; - static PyThreadState *thread_for_sentinel = 0; - - if ( sentinel == 0 ) { - unsigned long stackspace = StackSpace(); - -#ifdef MAXIMUM_STACK_SIZE - /* See the comment at the definition */ - if ( stackspace > MAXIMUM_STACK_SIZE ) - stackspace = MAXIMUM_STACK_SIZE; -#endif - sentinel = &here - stackspace + MINIMUM_STACK_SIZE; - } - if ( thread_for_sentinel == 0 ) { - thread_for_sentinel = PyThreadState_Get(); - } - if ( &here < sentinel ) { - if (thread_for_sentinel == PyThreadState_Get()) { - return -1; - } - } - return 0; -} -#endif /* USE_STACKCHECK */ - -#if !TARGET_API_MAC_OSX -void -PyErr_SetInterrupt(void) -{ - interrupted = 1; -} - -/* The catcher routine (which may not be used for all compilers) */ -static RETSIGTYPE -intcatcher(sig) - int sig; -{ - interrupted = 1; - signal(SIGINT, intcatcher); -} - -void -PyOS_InitInterrupts() -{ - if (signal(SIGINT, SIG_IGN) != SIG_IGN) - signal(SIGINT, intcatcher); -} - -void -PyOS_FiniInterrupts() -{ -} - -/* Check whether we are in the foreground */ -static int -PyMac_InForeground(void) -{ - static ProcessSerialNumber ours; - static inited; - ProcessSerialNumber curfg; - Boolean eq; - - if ( inited == 0 ) { - (void)GetCurrentProcess(&ours); - inited = 1; - } - if ( GetFrontProcess(&curfg) < 0 ) - eq = 1; - else if ( SameProcess(&ours, &curfg, &eq) < 0 ) - eq = 1; - return (int)eq; -} - -/* -** This routine scans the event queue looking for cmd-. -*/ -static void -scan_event_queue(force) - int force; -{ - if ( interrupted || (!schedparams.check_interrupt && !force) ) - return; - if ( CheckEventQueueForUserCancel() ) - interrupted = 1; -} - -int -PyErr_CheckSignals() -{ - if (schedparams.enabled) { - if ( interrupted || (unsigned long)TickCount() > schedparams.next_check ) { - scan_event_queue(0); - if (interrupted) { - interrupted = 0; - PyErr_SetNone(PyExc_KeyboardInterrupt); - return -1; - } - if ( PyMac_Yield() < 0) - return -1; - schedparams.next_check = (unsigned long)TickCount() - + schedparams.check_interval; - } - } - return 0; -} - -int -PyOS_InterruptOccurred() -{ - scan_event_queue(0); - if ( !interrupted ) - return 0; - interrupted = 0; - return 1; -} -#endif - -int -PyMac_SetEventHandler(PyObject *evh) -{ - if ( evh && python_event_handler ) { - PyErr_SetString(PyExc_RuntimeError, "Python event handler already set"); - return 0; - } - if ( python_event_handler ) - Py_DECREF(python_event_handler); - if ( evh ) - Py_INCREF(evh); - python_event_handler = evh; - return 1; -} - -/* -** Handle an event, either one found in the mainloop eventhandler or -** one passed back from the python program. -*/ -void -PyMac_HandleEventIntern(evp) - EventRecord *evp; -{ -#ifdef __MWERKS__ - { - int siouxdidit; - - /* If SIOUX wants it we're done */ - siouxdidit = SIOUXHandleOneEvent(evp); - if ( siouxdidit ) - return; - } -#else - /* Other compilers are just unlucky... */ -#endif /* !__MWERKS__ */ -} - -/* -** Handle an event, either through HandleEvent or by passing it to the Python -** event handler. -*/ -int -PyMac_HandleEvent(evp) - EventRecord *evp; -{ - PyObject *rv; - - if ( python_event_handler ) { - rv = PyObject_CallFunction(python_event_handler, "(O&)", - PyMac_BuildEventRecord, evp); - if ( rv ) - Py_DECREF(rv); - else - return -1; /* Propagate exception */ - } else { - PyMac_HandleEventIntern(evp); - } - return 0; -} - -#if !TARGET_API_MAC_OSX -/* -** Yield the CPU to other tasks without processing events. -*/ -int -PyMac_DoYield(int maxsleep, int maycallpython) -{ - EventRecord ev; - int gotone; - long latest_time_ready; - static int in_here = 0; - - in_here++; - - /* - ** Check which of the eventloop cases we have: - ** - process events - ** - don't process events but do yield - ** - do neither - */ - if( in_here > 1 || !schedparams.process_events || - (python_event_handler && !maycallpython) ) { - if ( maxsleep >= 0 ) { - /* XXXX Need to do something here */ - } - } else { - latest_time_ready = TickCount() + maxsleep; - do { - /* XXXX Hack by Jack. - ** In time.sleep() you can click to another application - ** once only. If you come back to Python you cannot get away - ** again. - **/ - gotone = WaitNextEvent(schedparams.process_events, &ev, maxsleep, NULL); - /* Get out quickly if nothing interesting is happening */ - if ( !gotone || ev.what == nullEvent ) - break; - if ( PyMac_HandleEvent(&ev) < 0 ) { - in_here--; - return -1; - } - maxsleep = latest_time_ready - TickCount(); - } while ( maxsleep > 0 ); - } - in_here--; - return 0; -} - -/* -** Process events and/or yield the CPU to other tasks if opportune -*/ -int -PyMac_Yield() { - unsigned long maxsleep; - - if( PyMac_InForeground() ) - maxsleep = 0; - else - maxsleep = schedparams.bg_yield; - - return PyMac_DoYield(maxsleep, 1); -} - -/* -** Return current scheduler parameters -*/ -void -PyMac_GetSchedParams(PyMacSchedParams *sp) -{ - sp->check_interrupt = schedparams.check_interrupt; - sp->process_events = schedparams.process_events; - sp->besocial = schedparams.besocial; - sp->check_interval = schedparams.check_interval / 60.0; - sp->bg_yield = schedparams.bg_yield / 60.0; -} - -/* -** Set current scheduler parameters -*/ -void -PyMac_SetSchedParams(PyMacSchedParams *sp) -{ - schedparams.check_interrupt = sp->check_interrupt; - schedparams.process_events = sp->process_events; - schedparams.besocial = sp->besocial; - schedparams.check_interval = (unsigned long)(sp->check_interval*60); - schedparams.bg_yield = (unsigned long)(sp->bg_yield*60); - if ( schedparams.check_interrupt || schedparams.process_events || - schedparams.besocial ) - schedparams.enabled = 1; - else - schedparams.enabled = 0; - schedparams.next_check = 0; /* Check immedeately */ -} - -/* -** Install our menu bar. -*/ -void -PyMac_InitMenuBar() -{ - MenuHandle applemenu; - Str255 about_text; - static unsigned char about_sioux[] = "\pAbout SIOUX"; - - if ( sioux_mbar ) return; - if ( (sioux_mbar=GetMenuBar()) == NULL || GetMenuHandle(SIOUX_APPLEID) == NULL) { - /* Sioux menu not installed yet. Do so */ - SIOUXSetupMenus(); - if ( (sioux_mbar=GetMenuBar()) == NULL ) - return; - } - if ( (applemenu=GetMenuHandle(SIOUX_APPLEID)) == NULL ) return; - GetMenuItemText(applemenu, 1, about_text); - if ( about_text[0] == about_sioux[0] && - strncmp((char *)(about_text+1), (char *)(about_sioux+1), about_text[0]) == 0 ) - SetMenuItemText(applemenu, 1, "\pAbout Python..."); -} - -/* -** Restore sioux menu bar -*/ -void -PyMac_RestoreMenuBar() -{ - MenuBarHandle curmenubar; - - curmenubar = GetMenuBar(); - if ( sioux_mbar ) { - SetMenuBar(sioux_mbar); - DrawMenuBar(); - } else { - PyMac_InitMenuBar(); - DrawMenuBar(); - } -} - -void -PyMac_RaiseConsoleWindow() -{ - /* Note: this is a hack. SIOUXTextWindow is SIOUX's internal structure - ** and we happen to know that the first entry is the window pointer. - */ - extern WindowRef *SIOUXTextWindow; - - if ( SIOUXTextWindow == NULL || *SIOUXTextWindow == NULL ) - return; - if ( FrontWindow() != *SIOUXTextWindow ) - BringToFront(*SIOUXTextWindow); -} - -/* -** Our replacement about box -*/ - -#include "patchlevel.h" - -void -SIOUXDoAboutBox(void) -{ - DialogPtr theDialog; - WindowPtr theWindow; - short item; - short fontID; - - if( (theDialog = GetNewDialog(ABOUT_ID, NULL, (WindowPtr)-1)) == NULL ) - return; - theWindow = GetDialogWindow(theDialog); - SetPortWindowPort(theWindow); - GetFNum("\pPython-Sans", &fontID); - if (fontID == 0) - fontID = kFontIDGeneva; - TextFont(fontID); - TextSize(9); - ParamText(Pstring(PY_VERSION), "\p", "\p", "\p"); - ShowWindow(theWindow); - ModalDialog(NULL, &item); - DisposeDialog(theDialog); -} - -#endif /* !TARGET_API_MAC_OSX */ diff --git a/Mac/Python/macimport.c b/Mac/Python/macimport.c deleted file mode 100644 index e6c432b5d5..0000000000 --- a/Mac/Python/macimport.c +++ /dev/null @@ -1,445 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - - -#include "Python.h" - -#include "macglue.h" -#include "marshal.h" -#include "import.h" -#include "importdl.h" - -#include "pythonresources.h" - -#include -#include -#include -#include -#include - -typedef void (*dl_funcptr)(); -#define FUNCNAME_PATTERN "init%.200s" - -static int -fssequal(FSSpec *fs1, FSSpec *fs2) -{ - if ( fs1->vRefNum != fs2->vRefNum || fs1->parID != fs2->parID ) - return 0; - return EqualString(fs1->name, fs2->name, false, true); -} -/* -** findnamedresource - Common code for the various *ResourceModule functions. -** Check whether a file contains a resource of the correct name and type, and -** optionally return the value in it. -*/ -static int -findnamedresource( - PyStringObject *obj, - char *module, - char *filename, - OSType restype, - StringPtr dataptr) -{ - FSSpec fss; - FInfo finfo; - short oldrh, filerh; - int ok; - Handle h; - - /* - ** Find_module takes care of interning all - ** sys.path components. We then keep a record of all sys.path - ** components for which GetFInfo has failed (usually because the - ** component in question is a folder), and we don't try opening these - ** as resource files again. - */ -#define MAXPATHCOMPONENTS 32 - static PyStringObject *not_a_file[MAXPATHCOMPONENTS]; - static int max_not_a_file = 0; - int i; - - if (obj && PyString_Check(obj) && PyString_CHECK_INTERNED(obj) ) { - for( i=0; i< max_not_a_file; i++ ) - if ( obj == not_a_file[i] ) - return 0; - } - if ( FSMakeFSSpec(0, 0, Pstring(filename), &fss) != noErr ) { - /* doesn't exist or is folder */ - if ( obj && max_not_a_file < MAXPATHCOMPONENTS && PyString_Check(obj) && PyString_CHECK_INTERNED(obj) ) { - Py_INCREF(obj); - not_a_file[max_not_a_file++] = obj; - if (Py_VerboseFlag > 1) - PySys_WriteStderr("# %s is not a file\n", filename); - } - return 0; - } - if ( fssequal(&fss, &PyMac_ApplicationFSSpec) ) { - /* - ** Special case: the application itself. Use a shortcut to - ** forestall opening and closing the application numerous times - ** (which is dead slow when running from CDROM) - */ - oldrh = CurResFile(); - UseResFile(PyMac_AppRefNum); - filerh = -1; - } else { - if ( FSpGetFInfo(&fss, &finfo) != noErr ) { - /* doesn't exist or is folder */ - if ( obj && max_not_a_file < MAXPATHCOMPONENTS && PyString_Check(obj) && PyString_CHECK_INTERNED(obj) ) { - Py_INCREF(obj); - not_a_file[max_not_a_file++] = obj; - if (Py_VerboseFlag > 1) - PySys_WriteStderr("# %s is not a file\n", filename); - } - return 0; - } - oldrh = CurResFile(); - filerh = FSpOpenResFile(&fss, fsRdPerm); - if ( filerh == -1 ) - return 0; - UseResFile(filerh); - } - if ( dataptr == NULL ) - SetResLoad(0); - if (Py_VerboseFlag > 1) - PySys_WriteStderr("# Look for ('PYC ', %s) in %s\n", module, filename); - h = Get1NamedResource(restype, Pstring(module)); - SetResLoad(1); - ok = (h != NULL); - if ( ok && dataptr != NULL ) { - HLock(h); - /* XXXX Unsafe if resource not correctly formatted! */ - /* for ppc we take the first pstring */ - *dataptr = **h; - memcpy(dataptr+1, (*h)+1, (int)*dataptr); - HUnlock(h); - } - if ( filerh != -1 ) - CloseResFile(filerh); - UseResFile(oldrh); - return ok; -} - -/* -** Returns true if the argument has a resource fork, and it contains -** a 'PYC ' resource of the correct name -*/ -int -PyMac_FindResourceModule(obj, module, filename) -PyStringObject *obj; -char *module; -char *filename; -{ - int ok; - - ok = findnamedresource(obj, module, filename, 'PYC ', (StringPtr)0); - return ok; -} - -/* -** Returns true if the argument has a resource fork, and it contains -** a 'PYD ' resource of the correct name -*/ -int -PyMac_FindCodeResourceModule(obj, module, filename) -PyStringObject *obj; -char *module; -char *filename; -{ - int ok; - - ok = findnamedresource(obj, module, filename, 'PYD ', (StringPtr)0); - return ok; -} - - -/* -** Load the specified module from a code resource -*/ -PyObject * -PyMac_LoadCodeResourceModule(name, pathname) - char *name; - char *pathname; -{ - PyObject *m, *d, *s; - char funcname[258]; - char *lastdot, *shortname, *packagecontext; - dl_funcptr p = NULL; - Str255 fragmentname; - CFragConnectionID connID; - Ptr mainAddr; - Str255 errMessage; - OSErr err; - char buf[512]; - Ptr symAddr; - CFragSymbolClass class; - - if ((m = _PyImport_FindExtension(name, name)) != NULL) { - Py_INCREF(m); - return m; - } - lastdot = strrchr(name, '.'); - if (lastdot == NULL) { - packagecontext = NULL; - shortname = name; - } - else { - packagecontext = name; - shortname = lastdot+1; - } - PyOS_snprintf(funcname, sizeof(funcname), FUNCNAME_PATTERN, shortname); - if( !findnamedresource((PyStringObject *)0, name, pathname, 'PYD ', fragmentname)) { - PyErr_SetString(PyExc_ImportError, "PYD resource not found"); - return NULL; - } - - /* Load the fragment - (or return the connID if it is already loaded */ - err = GetSharedLibrary(fragmentname, kCompiledCFragArch, - kLoadCFrag, &connID, &mainAddr, - errMessage); - if ( err ) { - PyOS_snprintf(buf, sizeof(buf), "%.*s: %.200s", - errMessage[0], errMessage+1, - PyMac_StrError(err)); - PyErr_SetString(PyExc_ImportError, buf); - return NULL; - } - /* Locate the address of the correct init function */ - err = FindSymbol(connID, Pstring(funcname), &symAddr, &class); - if ( err ) { - PyOS_snprintf(buf, sizeof(buf), "%s: %.200s", - funcname, PyMac_StrError(err)); - PyErr_SetString(PyExc_ImportError, buf); - return NULL; - } - p = (dl_funcptr)symAddr; - if (p == NULL) { - PyErr_Format(PyExc_ImportError, - "dynamic module does not define init function (%.200s)", - funcname); - return NULL; - } - _Py_PackageContext = packagecontext; - (*p)(); - _Py_PackageContext = NULL; - if (PyErr_Occurred()) - return NULL; - if (_PyImport_FixupExtension(name, name) == NULL) - return NULL; - - m = PyDict_GetItemString(PyImport_GetModuleDict(), name); - if (m == NULL) { - PyErr_SetString(PyExc_SystemError, - "dynamic module not initialized properly"); - return NULL; - } - /* Remember the filename as the __file__ attribute */ - d = PyModule_GetDict(m); - s = PyString_FromString(pathname); - if (s == NULL || PyDict_SetItemString(d, "__file__", s) != 0) - PyErr_Clear(); /* Not important enough to report */ - Py_XDECREF(s); - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # pyd fragment %#s loaded from %s\n", - name, fragmentname, pathname); - Py_INCREF(m); - return m; -} - -/* -** Load the specified module from a resource -*/ -PyObject * -PyMac_LoadResourceModule(module, filename) -char *module; -char *filename; -{ - FSSpec fss; - FInfo finfo; - short oldrh, filerh; - Handle h; - OSErr err; - PyObject *m, *co; - long num, size; - - if ( (err=FSMakeFSSpec(0, 0, Pstring(filename), &fss)) != noErr ) - goto error; - if ( fssequal(&fss, &PyMac_ApplicationFSSpec) ) { - /* - ** Special case: the application itself. Use a shortcut to - ** forestall opening and closing the application numerous times - ** (which is dead slow when running from CDROM) - */ - oldrh = CurResFile(); - UseResFile(PyMac_AppRefNum); - filerh = -1; - } else { - if ( (err=FSpGetFInfo(&fss, &finfo)) != noErr ) - goto error; - oldrh = CurResFile(); - filerh = FSpOpenResFile(&fss, fsRdPerm); - if ( filerh == -1 ) { - err = ResError(); - goto error; - } - UseResFile(filerh); - } - h = Get1NamedResource('PYC ', Pstring(module)); - if ( h == NULL ) { - err = ResError(); - goto error; - } - HLock(h); - /* - ** XXXX The next few lines are intimately tied to the format of pyc - ** files. I'm not sure whether this code should be here or in import.c -- Jack - */ - size = GetHandleSize(h); - if ( size < 8 ) { - PyErr_SetString(PyExc_ImportError, "Resource too small"); - co = NULL; - } else { - num = (*h)[0] & 0xff; - num = num | (((*h)[1] & 0xff) << 8); - num = num | (((*h)[2] & 0xff) << 16); - num = num | (((*h)[3] & 0xff) << 24); - if ( num != PyImport_GetMagicNumber() ) { - PyErr_SetString(PyExc_ImportError, "Bad MAGIC in resource"); - co = NULL; - } else { - co = PyMarshal_ReadObjectFromString((*h)+8, size-8); - /* - ** Normally, byte 4-7 are the time stamp, but that is not used - ** for 'PYC ' resources. We abuse byte 4 as a flag to indicate - ** that it is a package rather than an ordinary module. - ** See also py_resource.py. (jvr) - */ - if ((*h)[4] & 0xff) { - /* it's a package */ - /* Set __path__ to the package name */ - PyObject *d, *s; - int err; - - m = PyImport_AddModule(module); - if (m == NULL) { - co = NULL; - goto packageerror; - } - d = PyModule_GetDict(m); - s = PyString_InternFromString(module); - if (s == NULL) { - co = NULL; - goto packageerror; - } - err = PyDict_SetItemString(d, "__path__", s); - Py_DECREF(s); - if (err != 0) { - co = NULL; - goto packageerror; - } - } - } - } -packageerror: - HUnlock(h); - if ( filerh != -1 ) - CloseResFile(filerh); - else - ReleaseResource(h); - UseResFile(oldrh); - if ( co ) { - m = PyImport_ExecCodeModuleEx(module, co, ""); - Py_DECREF(co); - } else { - m = NULL; - } - if (Py_VerboseFlag) - PySys_WriteStderr("import %s # pyc resource from %s\n", - module, filename); - return m; -error: - { - char buf[512]; - - PyOS_snprintf(buf, sizeof(buf), "%s: %s", filename, PyMac_StrError(err)); - PyErr_SetString(PyExc_ImportError, buf); - return NULL; - } -} - -/* -** Look for a module in a single folder. Upon entry buf and len -** point to the folder to search, upon exit they refer to the full -** pathname of the module found (if any). -*/ -struct filedescr * -PyMac_FindModuleExtension(char *buf, size_t *lenp, char *module) -{ - struct filedescr *fdp; - unsigned char fnbuf[64]; - int modnamelen = strlen(module); - FSSpec fss; - short refnum; - long dirid; - - /* - ** Copy the module name to the buffer (already :-terminated) - ** We also copy the first suffix, if this matches immedeately we're - ** lucky and return immedeately. - */ - if ( !_PyImport_Filetab[0].suffix ) - return 0; - - strcpy(buf+*lenp, _PyImport_Filetab[0].suffix); - if ( FSMakeFSSpec(0, 0, Pstring(buf), &fss) == noErr ) - return _PyImport_Filetab; - /* - ** We cannot check for fnfErr (unfortunately), it can mean either that - ** the file doesn't exist (fine, we try others) or the path leading to it. - */ - refnum = fss.vRefNum; - dirid = fss.parID; - if ( refnum == 0 || dirid == 0 ) /* Fail on nonexistent dir */ - return 0; - /* - ** We now have the folder parameters. Setup the field for the filename - */ - if ( modnamelen > 54 ) return 0; /* Leave room for extension */ - strcpy((char *)fnbuf+1, module); - buf[*lenp] = '\0'; - - for( fdp = _PyImport_Filetab+1; fdp->suffix; fdp++ ) { - strcpy((char *)fnbuf+1+modnamelen, fdp->suffix); - fnbuf[0] = strlen((char *)fnbuf+1); - if (Py_VerboseFlag > 1) - PySys_WriteStderr("# trying %s%s\n", buf, fdp->suffix); - if ( FSMakeFSSpec(refnum, dirid, fnbuf, &fss) == noErr ) { - /* Found it. */ - strcpy(buf+*lenp, fdp->suffix); - return fdp; - } - } - return 0; -} diff --git a/Mac/Python/macmain.c b/Mac/Python/macmain.c deleted file mode 100644 index d257142976..0000000000 --- a/Mac/Python/macmain.c +++ /dev/null @@ -1,640 +0,0 @@ -/*********************************************************** -Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, -The Netherlands. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -******************************************************************/ - -/* Python interpreter main program */ - -#include "Python.h" -#include "pythonresources.h" -#include "import.h" -#include "marshal.h" -#include "macglue.h" - -#ifdef WITHOUT_FRAMEWORKS -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#else -#include -#endif /* WITHOUT_FRAMEWORKS */ - -#ifdef __MWERKS__ -#include -#define USE_SIOUX -extern int ccommand(char ***); -#if __profile__ == 1 -#include -#endif /* __profile__ */ -#endif /* __MWERKS__ */ - -#include -#ifdef USE_MAC_SHARED_LIBRARY -extern PyMac_AddLibResources(void); -#endif - -#define STARTUP "PythonStartup" - -#define COPYRIGHT \ - "Type \"copyright\", \"credits\" or \"license\" for more information." - -short PyMac_AppRefNum; /* RefNum of application resource fork */ - -/* For Py_GetArgcArgv(); set by main() */ -static char **orig_argv; -static int orig_argc; - -/* A flag which remembers whether the user has acknowledged all the console -** output (by typing something) -*/ -#define STATE_UNKNOWN 0 -#define STATE_LASTREAD 1 -#define STATE_LASTWRITE 2 -int console_output_state = STATE_UNKNOWN; - -PyMac_PrefRecord PyMac_options; - -static void PyMac_Main(int, char **, char *); /* Forward */ -void PyMac_Exit(int); /* Forward */ - -/* Initialize the Mac toolbox world */ - -static void -init_mac_world(void) -{ - InitCursor(); -} - -/* -** PyMac_InteractiveOptions - Allow user to set options if option key is pressed -*/ -static void -PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp) -{ - KeyMap rmap; - unsigned char *map; - short item, type; - ControlHandle handle; - DialogPtr dialog; - Rect rect; - - /* - ** If the preferences disallows interactive options we return, - ** similarly of