blob: df9f7f79c691c8f9c456046a5fda4af3d0548ac9 [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__
12/*
13** This part is copied from MW Startup.c, which is
14** Copyright © 1993 metrowerks inc. All Rights Reserved.
15*/
16#include <setjmp.h>
Jack Jansen2e4679d1995-02-13 11:39:17 +000017#include <stdio.h>
18
Jack Jansen2a586381995-06-14 14:44:17 +000019void *__local_destructor_chain; /* chain of local objects that need destruction */
Jack Jansen2e4679d1995-02-13 11:39:17 +000020
21 /* public data */
22
23QDGlobals qd; /* define the Quickdraw globals here! */
24jmp_buf __program_exit; /* exit() does a longjmp() to here */
25void (*__atexit_hook)(void); /* atexit() sets this up if it is ever called */
26void (*___atexit_hook)(void); /* _atexit() sets this up if it is ever called */
27int __aborting; /* abort() sets this and longjmps to __program_exit */
Guido van Rossum7c496ec1995-02-20 23:44:43 +000028#endif
Jack Jansen2e4679d1995-02-13 11:39:17 +000029
Guido van Rossum7c496ec1995-02-20 23:44:43 +000030/*
31** Variables passed from shared lib initialization to PyMac_AddLibResources.
32*/
33static int library_fss_valid;
34static FSSpec library_fss;
35
Jack Jansen2e4679d1995-02-13 11:39:17 +000036/*
37** Routine called upon fragment load. We attempt to save the FSSpec from which we're
38** loaded. We always return noErr (we just continue without the resources).
39*/
Guido van Rossum7c496ec1995-02-20 23:44:43 +000040OSErr pascal
Jack Jansen2e4679d1995-02-13 11:39:17 +000041__sinit(InitBlockPtr data)
42{
Guido van Rossum7c496ec1995-02-20 23:44:43 +000043 if ( data == nil ) return noErr;
Jack Jansen2e4679d1995-02-13 11:39:17 +000044 if ( data->fragLocator.where == kOnDiskFlat ) {
45 library_fss = *data->fragLocator.u.onDisk.fileSpec;
46 library_fss_valid = 1;
47 } else if ( data->fragLocator.where == kOnDiskSegmented ) {
48 library_fss = *data->fragLocator.u.inSegs.fileSpec;
49 library_fss_valid = 1;
50 }
51 return noErr;
52}
53
54/*
55** Insert the library resources into the search path. Put them after
56** the resources from the application (which we assume is the current
57** resource file). Again, we ignore errors.
58*/
59void
60PyMac_AddLibResources()
61{
62 OSErr err;
63 short fd, curfd;
64
65 if ( !library_fss_valid )
66 return;
Jack Jansenfc0ff421995-02-13 22:43:38 +000067 fd = FSpOpenResFile(&library_fss, fsRdPerm);
Jack Jansen2e4679d1995-02-13 11:39:17 +000068}
Guido van Rossum7c496ec1995-02-20 23:44:43 +000069