diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1995-02-13 11:39:17 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1995-02-13 11:39:17 (GMT) |
commit | 2e4679db8ef02401a8e368c70a3272292420fecc (patch) | |
tree | 279a4eb26553c0c616674f34e3897597f7087489 /Mac/Python/macshlglue.c | |
parent | c6647c607995a4bbf729575161c721c1f89e51b4 (diff) | |
download | cpython-2e4679db8ef02401a8e368c70a3272292420fecc.zip cpython-2e4679db8ef02401a8e368c70a3272292420fecc.tar.gz cpython-2e4679db8ef02401a8e368c70a3272292420fecc.tar.bz2 |
Glue for the python shared library: an init routine that remembers
where we're loaded from and PyMac_AddLibResources() which adds that
file to the resource file list.
Diffstat (limited to 'Mac/Python/macshlglue.c')
-rw-r--r-- | Mac/Python/macshlglue.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Mac/Python/macshlglue.c b/Mac/Python/macshlglue.c new file mode 100644 index 0000000..a6885d4 --- /dev/null +++ b/Mac/Python/macshlglue.c @@ -0,0 +1,65 @@ +/* +** mac shared lib glue. +** +** Partially stolen from MW Startup.c, which is +** Copyright © 1993 metrowerks inc. All Rights Reserved. +*/ + +#include <CPlusLibPPC.h> +#include <Quickdraw.h> +#include <SegLoad.h> +#include <setjmp.h> +#include <FragLoad.h> +#include <Files.h> +#include <Resources.h> + +#include <stdio.h> + +char *macstrerror(); + +DestructorChain *__local_destructor_chain; /* chain of local objects that need destruction */ + + /* public data */ + +QDGlobals qd; /* define the Quickdraw globals here! */ +jmp_buf __program_exit; /* exit() does a longjmp() to here */ +void (*__atexit_hook)(void); /* atexit() sets this up if it is ever called */ +void (*___atexit_hook)(void); /* _atexit() sets this up if it is ever called */ +int __aborting; /* abort() sets this and longjmps to __program_exit */ + +int library_fss_valid; +FSSpec library_fss; +/* +** Routine called upon fragment load. We attempt to save the FSSpec from which we're +** loaded. We always return noErr (we just continue without the resources). +*/ +OSErr +__sinit(InitBlockPtr data) +{ + if ( data == NULL ) return noErr; + if ( data->fragLocator.where == kOnDiskFlat ) { + library_fss = *data->fragLocator.u.onDisk.fileSpec; + library_fss_valid = 1; + } else if ( data->fragLocator.where == kOnDiskSegmented ) { + library_fss = *data->fragLocator.u.inSegs.fileSpec; + library_fss_valid = 1; + } + return noErr; +} + +/* +** Insert the library resources into the search path. Put them after +** the resources from the application (which we assume is the current +** resource file). Again, we ignore errors. +*/ +void +PyMac_AddLibResources() +{ + OSErr err; + short fd, curfd; + + if ( !library_fss_valid ) + return; + fd = FSpOpenResFile(&library_fss, fsRdWrShPerm); +} + |