diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2000-01-07 14:53:31 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2000-01-07 14:53:31 (GMT) |
commit | 205b435c506c3024d25746d534a45e66010cbd61 (patch) | |
tree | 5ad6fe01f5c126291d0b4f915fa1f93352627fd3 /Mac | |
parent | d2783da63ec5866eb482986555f34d6698f21645 (diff) | |
download | cpython-205b435c506c3024d25746d534a45e66010cbd61.zip cpython-205b435c506c3024d25746d534a45e66010cbd61.tar.gz cpython-205b435c506c3024d25746d534a45e66010cbd61.tar.bz2 |
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/Python/macapplication.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Mac/Python/macapplication.c b/Mac/Python/macapplication.c index 19c3ab1..0fe1c70 100644 --- a/Mac/Python/macapplication.c +++ b/Mac/Python/macapplication.c @@ -25,6 +25,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* Macintosh Python main program for both applets and interpreter */ #include <Resources.h> +#include <CodeFragments.h> #ifdef __CFM68K__ #pragma lib_export on @@ -35,9 +36,41 @@ extern void PyMac_InitApplet(); extern void PyMac_InitApplication(); #endif /* USE_MAC_APPLET_SUPPORT */ + +/* +** 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__"); @@ -45,6 +78,7 @@ main() { PyMac_InitApplet(); else PyMac_InitApplication(); + } #else PyMac_InitApplication(); #endif /* USE_MAC_APPLET_SUPPORT */ |