blob: fc2adaf2565ecb3309dbdfa53f0fb786cfc25dd2 [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{
Guido van Rossum7c496ec1995-02-20 23:44:43 +000045 if ( data == nil ) return noErr;
Jack Jansen2e4679d1995-02-13 11:39:17 +000046 if ( data->fragLocator.where == kOnDiskFlat ) {
47 library_fss = *data->fragLocator.u.onDisk.fileSpec;
48 library_fss_valid = 1;
49 } else if ( data->fragLocator.where == kOnDiskSegmented ) {
50 library_fss = *data->fragLocator.u.inSegs.fileSpec;
51 library_fss_valid = 1;
52 }
53 return noErr;
54}
55
56/*
57** Insert the library resources into the search path. Put them after
58** the resources from the application (which we assume is the current
59** resource file). Again, we ignore errors.
60*/
61void
62PyMac_AddLibResources()
63{
Jack Jansen2e4679d1995-02-13 11:39:17 +000064 if ( !library_fss_valid )
65 return;
Jack Jansen83f45401995-10-09 23:25:32 +000066 (void)FSpOpenResFile(&library_fss, fsRdPerm);
Jack Jansen2e4679d1995-02-13 11:39:17 +000067}
Guido van Rossum7c496ec1995-02-20 23:44:43 +000068