Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 1 | /* |
Guido van Rossum | 7c496ec | 1995-02-20 23:44:43 +0000 | [diff] [blame] | 2 | ** Mac shared lib glue. |
Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 3 | */ |
| 4 | |
Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 5 | #include <Quickdraw.h> |
| 6 | #include <SegLoad.h> |
Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 7 | #include <FragLoad.h> |
| 8 | #include <Files.h> |
| 9 | #include <Resources.h> |
| 10 | |
Guido van Rossum | 7c496ec | 1995-02-20 23:44:43 +0000 | [diff] [blame] | 11 | #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 Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 17 | #include <stdio.h> |
| 18 | |
Jack Jansen | e2b5d04 | 1995-11-14 10:26:00 +0000 | [diff] [blame] | 19 | /* void *__local_destructor_chain; /* chain of local objects that need destruction */ |
Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 20 | |
| 21 | /* public data */ |
| 22 | |
| 23 | QDGlobals qd; /* define the Quickdraw globals here! */ |
| 24 | jmp_buf __program_exit; /* exit() does a longjmp() to here */ |
| 25 | void (*__atexit_hook)(void); /* atexit() sets this up if it is ever called */ |
| 26 | void (*___atexit_hook)(void); /* _atexit() sets this up if it is ever called */ |
| 27 | int __aborting; /* abort() sets this and longjmps to __program_exit */ |
Guido van Rossum | 7c496ec | 1995-02-20 23:44:43 +0000 | [diff] [blame] | 28 | #endif |
Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 29 | |
Guido van Rossum | 7c496ec | 1995-02-20 23:44:43 +0000 | [diff] [blame] | 30 | /* |
| 31 | ** Variables passed from shared lib initialization to PyMac_AddLibResources. |
| 32 | */ |
| 33 | static int library_fss_valid; |
| 34 | static FSSpec library_fss; |
| 35 | |
Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 36 | /* |
| 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 Rossum | 7c496ec | 1995-02-20 23:44:43 +0000 | [diff] [blame] | 40 | OSErr pascal |
Jack Jansen | e2b5d04 | 1995-11-14 10:26:00 +0000 | [diff] [blame] | 41 | PythonCore_init(InitBlockPtr data) |
Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 42 | { |
Guido van Rossum | 7c496ec | 1995-02-20 23:44:43 +0000 | [diff] [blame] | 43 | if ( data == nil ) return noErr; |
Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 44 | 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 | */ |
| 59 | void |
| 60 | PyMac_AddLibResources() |
| 61 | { |
Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 62 | if ( !library_fss_valid ) |
| 63 | return; |
Jack Jansen | 83f4540 | 1995-10-09 23:25:32 +0000 | [diff] [blame] | 64 | (void)FSpOpenResFile(&library_fss, fsRdPerm); |
Jack Jansen | 2e4679d | 1995-02-13 11:39:17 +0000 | [diff] [blame] | 65 | } |
Guido van Rossum | 7c496ec | 1995-02-20 23:44:43 +0000 | [diff] [blame] | 66 | |