Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 18 | char *macstrerror(); |
| 19 | |
| 20 | DestructorChain *__local_destructor_chain; /* chain of local objects that need destruction */ |
| 21 | |
| 22 | /* public data */ |
| 23 | |
| 24 | QDGlobals qd; /* define the Quickdraw globals here! */ |
| 25 | jmp_buf __program_exit; /* exit() does a longjmp() to here */ |
| 26 | void (*__atexit_hook)(void); /* atexit() sets this up if it is ever called */ |
| 27 | void (*___atexit_hook)(void); /* _atexit() sets this up if it is ever called */ |
| 28 | int __aborting; /* abort() sets this and longjmps to __program_exit */ |
| 29 | |
| 30 | int library_fss_valid; |
| 31 | FSSpec 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 | */ |
| 36 | OSErr |
| 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 | */ |
| 55 | void |
| 56 | PyMac_AddLibResources() |
| 57 | { |
| 58 | OSErr err; |
| 59 | short fd, curfd; |
| 60 | |
| 61 | if ( !library_fss_valid ) |
| 62 | return; |
Jack Jansen | fc0ff42 | 1995-02-13 22:43:38 +0000 | [diff] [blame^] | 63 | fd = FSpOpenResFile(&library_fss, fsRdPerm); |
Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 64 | } |
| 65 | |