blob: 9753460a16201eea2764ec5dbc2939ee4b66bba2 [file] [log] [blame]
Jack Jansen2e4679d1995-02-13 11:39:17 +00001/*
Guido van Rossum7c496ec1995-02-20 23:44:43 +00002** Mac shared lib glue.
Jack Jansen2e4679d1995-02-13 11:39:17 +00003*/
4
Jack Jansen2e4679d1995-02-13 11:39:17 +00005#include <Quickdraw.h>
6#include <SegLoad.h>
Jack Jansen2e4679d1995-02-13 11:39:17 +00007#include <FragLoad.h>
8#include <Files.h>
9#include <Resources.h>
10
Guido van Rossum7c496ec1995-02-20 23:44:43 +000011#ifdef __MWERKS__
Jack Jansen56ed26e1996-02-20 16:25:31 +000012#ifdef PRE_CW8
Guido van Rossum7c496ec1995-02-20 23:44:43 +000013/*
14** This part is copied from MW Startup.c, which is
15** Copyright © 1993 metrowerks inc. All Rights Reserved.
16*/
17#include <setjmp.h>
Jack Jansen2e4679d1995-02-13 11:39:17 +000018#include <stdio.h>
19
Jack Jansene2b5d041995-11-14 10:26:00 +000020/* void *__local_destructor_chain; /* chain of local objects that need destruction */
Jack Jansen2e4679d1995-02-13 11:39:17 +000021
22 /* public data */
23
24QDGlobals qd; /* define the Quickdraw globals here! */
25jmp_buf __program_exit; /* exit() does a longjmp() to here */
26void (*__atexit_hook)(void); /* atexit() sets this up if it is ever called */
27void (*___atexit_hook)(void); /* _atexit() sets this up if it is ever called */
28int __aborting; /* abort() sets this and longjmps to __program_exit */
Guido van Rossum7c496ec1995-02-20 23:44:43 +000029#endif
Jack Jansen56ed26e1996-02-20 16:25:31 +000030#endif
Jack Jansen2e4679d1995-02-13 11:39:17 +000031
Guido van Rossum7c496ec1995-02-20 23:44:43 +000032/*
33** Variables passed from shared lib initialization to PyMac_AddLibResources.
34*/
35static int library_fss_valid;
36static FSSpec library_fss;
37
Jack Jansen2e4679d1995-02-13 11:39:17 +000038/*
39** Routine called upon fragment load. We attempt to save the FSSpec from which we're
40** loaded. We always return noErr (we just continue without the resources).
41*/
Guido van Rossum7c496ec1995-02-20 23:44:43 +000042OSErr pascal
Jack Jansene2b5d041995-11-14 10:26:00 +000043PythonCore_init(InitBlockPtr data)
Jack Jansen2e4679d1995-02-13 11:39:17 +000044{
Jack Jansen9ff06ce1996-08-19 11:17:33 +000045 /* Call the MW runtime's initialization routine */
46 __initialize();
Jack Jansen8ab11481996-02-29 16:10:32 +000047
Guido van Rossum7c496ec1995-02-20 23:44:43 +000048 if ( data == nil ) return noErr;
Jack Jansen2e4679d1995-02-13 11:39:17 +000049 if ( data->fragLocator.where == kOnDiskFlat ) {
50 library_fss = *data->fragLocator.u.onDisk.fileSpec;
51 library_fss_valid = 1;
52 } else if ( data->fragLocator.where == kOnDiskSegmented ) {
53 library_fss = *data->fragLocator.u.inSegs.fileSpec;
54 library_fss_valid = 1;
55 }
56 return noErr;
57}
58
59/*
60** Insert the library resources into the search path. Put them after
61** the resources from the application (which we assume is the current
62** resource file). Again, we ignore errors.
63*/
64void
65PyMac_AddLibResources()
66{
Jack Jansen2e4679d1995-02-13 11:39:17 +000067 if ( !library_fss_valid )
68 return;
Jack Jansen83f45401995-10-09 23:25:32 +000069 (void)FSpOpenResFile(&library_fss, fsRdPerm);
Jack Jansen2e4679d1995-02-13 11:39:17 +000070}
Guido van Rossum7c496ec1995-02-20 23:44:43 +000071