1995-02-13 12:39:17 +01:00
|
|
|
/*
|
1996-08-23 17:45:26 +02:00
|
|
|
** Shared library initialization code.
|
|
|
|
**
|
|
|
|
** This code calls the MetroWerks shared-library initialization code
|
|
|
|
** and performs one extra step: it remembers the FSSpec of the file
|
|
|
|
** we are loaded from, so we can later call PyMac_AddLibResources to
|
|
|
|
** add the file to our resource file chain.
|
|
|
|
**
|
|
|
|
** This file is needed for PythonCore and for any dynamically loaded
|
|
|
|
** module that has interesting resources in its .slb file.
|
|
|
|
** Use by replacing __initialize in the "CFM preferences" init field
|
|
|
|
** by __initialize_with_resources.
|
1995-02-13 12:39:17 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Quickdraw.h>
|
|
|
|
#include <SegLoad.h>
|
|
|
|
#include <FragLoad.h>
|
|
|
|
#include <Files.h>
|
|
|
|
#include <Resources.h>
|
|
|
|
|
1995-02-21 00:44:43 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Variables passed from shared lib initialization to PyMac_AddLibResources.
|
|
|
|
*/
|
|
|
|
static int library_fss_valid;
|
|
|
|
static FSSpec library_fss;
|
1995-02-13 12:39:17 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Routine called upon fragment load. We attempt to save the FSSpec from which we're
|
|
|
|
** loaded. We always return noErr (we just continue without the resources).
|
|
|
|
*/
|
1995-02-21 00:44:43 +01:00
|
|
|
OSErr pascal
|
1996-08-23 17:45:26 +02:00
|
|
|
__initialize_with_resources(InitBlockPtr data)
|
1995-02-13 12:39:17 +01:00
|
|
|
{
|
1996-08-19 13:17:33 +02:00
|
|
|
/* Call the MW runtime's initialization routine */
|
1996-08-23 17:45:26 +02:00
|
|
|
/* #ifdef __CFM68K__ */
|
|
|
|
#if 1
|
1996-08-19 13:17:33 +02:00
|
|
|
__initialize();
|
1996-08-19 17:10:50 +02:00
|
|
|
#else
|
|
|
|
__sinit();
|
|
|
|
#endif
|
1996-02-29 17:10:32 +01:00
|
|
|
|
1995-02-21 00:44:43 +01:00
|
|
|
if ( data == nil ) return noErr;
|
1995-02-13 12:39:17 +01:00
|
|
|
if ( data->fragLocator.where == kOnDiskFlat ) {
|
|
|
|
library_fss = *data->fragLocator.u.onDisk.fileSpec;
|
|
|
|
library_fss_valid = 1;
|
|
|
|
} else if ( data->fragLocator.where == kOnDiskSegmented ) {
|
|
|
|
library_fss = *data->fragLocator.u.inSegs.fileSpec;
|
|
|
|
library_fss_valid = 1;
|
|
|
|
}
|
|
|
|
return noErr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Insert the library resources into the search path. Put them after
|
|
|
|
** the resources from the application (which we assume is the current
|
|
|
|
** resource file). Again, we ignore errors.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
PyMac_AddLibResources()
|
|
|
|
{
|
|
|
|
if ( !library_fss_valid )
|
|
|
|
return;
|
1995-10-10 00:25:32 +01:00
|
|
|
(void)FSpOpenResFile(&library_fss, fsRdPerm);
|
1995-02-13 12:39:17 +01:00
|
|
|
}
|
1995-02-21 00:44:43 +01:00
|
|
|
|