blob: c079812692eebb6f378a9d72f31a8e6f1bd67d8b [file] [log] [blame]
Jack Jansen2e4679d1995-02-13 11:39:17 +00001/*
2** mac shared lib glue.
3**
4** Partially stolen from MW Startup.c, which is
5** Copyright © 1993 metrowerks inc. All Rights Reserved.
6*/
7
8#include <CPlusLibPPC.h>
9#include <Quickdraw.h>
10#include <SegLoad.h>
11#include <setjmp.h>
12#include <FragLoad.h>
13#include <Files.h>
14#include <Resources.h>
15
16#include <stdio.h>
17
18char *macstrerror();
19
20DestructorChain *__local_destructor_chain; /* chain of local objects that need destruction */
21
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 */
29
30int library_fss_valid;
31FSSpec library_fss;
32/*
33** Routine called upon fragment load. We attempt to save the FSSpec from which we're
34** loaded. We always return noErr (we just continue without the resources).
35*/
36OSErr
37__sinit(InitBlockPtr data)
38{
39 if ( data == NULL ) return noErr;
40 if ( data->fragLocator.where == kOnDiskFlat ) {
41 library_fss = *data->fragLocator.u.onDisk.fileSpec;
42 library_fss_valid = 1;
43 } else if ( data->fragLocator.where == kOnDiskSegmented ) {
44 library_fss = *data->fragLocator.u.inSegs.fileSpec;
45 library_fss_valid = 1;
46 }
47 return noErr;
48}
49
50/*
51** Insert the library resources into the search path. Put them after
52** the resources from the application (which we assume is the current
53** resource file). Again, we ignore errors.
54*/
55void
56PyMac_AddLibResources()
57{
58 OSErr err;
59 short fd, curfd;
60
61 if ( !library_fss_valid )
62 return;
Jack Jansenfc0ff421995-02-13 22:43:38 +000063 fd = FSpOpenResFile(&library_fss, fsRdPerm);
Jack Jansen2e4679d1995-02-13 11:39:17 +000064}
65