blob: 3c857f18f70f9b84e9a157a3937fdf1a863d1c9f [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
Guido van Rossum7c496ec1995-02-20 23:44:43 +00005#ifdef __powerc
Jack Jansen2e4679d1995-02-13 11:39:17 +00006#include <CPlusLibPPC.h>
Guido van Rossum7c496ec1995-02-20 23:44:43 +00007#endif
Jack Jansen2e4679d1995-02-13 11:39:17 +00008#include <Quickdraw.h>
9#include <SegLoad.h>
Jack Jansen2e4679d1995-02-13 11:39:17 +000010#include <FragLoad.h>
11#include <Files.h>
12#include <Resources.h>
13
Guido van Rossum7c496ec1995-02-20 23:44:43 +000014#ifdef __MWERKS__
15/*
16** This part is copied from MW Startup.c, which is
17** Copyright © 1993 metrowerks inc. All Rights Reserved.
18*/
19#include <setjmp.h>
Jack Jansen2e4679d1995-02-13 11:39:17 +000020#include <stdio.h>
21
Jack Jansen2e4679d1995-02-13 11:39:17 +000022DestructorChain *__local_destructor_chain; /* chain of local objects that need destruction */
23
24 /* public data */
25
26QDGlobals qd; /* define the Quickdraw globals here! */
27jmp_buf __program_exit; /* exit() does a longjmp() to here */
28void (*__atexit_hook)(void); /* atexit() sets this up if it is ever called */
29void (*___atexit_hook)(void); /* _atexit() sets this up if it is ever called */
30int __aborting; /* abort() sets this and longjmps to __program_exit */
Guido van Rossum7c496ec1995-02-20 23:44:43 +000031#endif
Jack Jansen2e4679d1995-02-13 11:39:17 +000032
Guido van Rossum7c496ec1995-02-20 23:44:43 +000033/*
34** Variables passed from shared lib initialization to PyMac_AddLibResources.
35*/
36static int library_fss_valid;
37static FSSpec library_fss;
38
Jack Jansen2e4679d1995-02-13 11:39:17 +000039/*
40** Routine called upon fragment load. We attempt to save the FSSpec from which we're
41** loaded. We always return noErr (we just continue without the resources).
42*/
Guido van Rossum7c496ec1995-02-20 23:44:43 +000043OSErr pascal
Jack Jansen2e4679d1995-02-13 11:39:17 +000044__sinit(InitBlockPtr data)
45{
Guido van Rossum7c496ec1995-02-20 23:44:43 +000046 if ( data == nil ) return noErr;
Jack Jansen2e4679d1995-02-13 11:39:17 +000047 if ( data->fragLocator.where == kOnDiskFlat ) {
48 library_fss = *data->fragLocator.u.onDisk.fileSpec;
49 library_fss_valid = 1;
50 } else if ( data->fragLocator.where == kOnDiskSegmented ) {
51 library_fss = *data->fragLocator.u.inSegs.fileSpec;
52 library_fss_valid = 1;
53 }
54 return noErr;
55}
56
57/*
58** Insert the library resources into the search path. Put them after
59** the resources from the application (which we assume is the current
60** resource file). Again, we ignore errors.
61*/
62void
63PyMac_AddLibResources()
64{
65 OSErr err;
66 short fd, curfd;
67
68 if ( !library_fss_valid )
69 return;
Jack Jansenfc0ff421995-02-13 22:43:38 +000070 fd = FSpOpenResFile(&library_fss, fsRdPerm);
Jack Jansen2e4679d1995-02-13 11:39:17 +000071}
Guido van Rossum7c496ec1995-02-20 23:44:43 +000072