#changed all email address to go through python.org
[python/dscho.git] / Mac / Python / macshlglue.c
blobdf9f7f79c691c8f9c456046a5fda4af3d0548ac9
1 /*
2 ** Mac shared lib glue.
3 */
5 #include <Quickdraw.h>
6 #include <SegLoad.h>
7 #include <FragLoad.h>
8 #include <Files.h>
9 #include <Resources.h>
11 #ifdef __MWERKS__
13 ** This part is copied from MW Startup.c, which is
14 ** Copyright © 1993 metrowerks inc. All Rights Reserved.
16 #include <setjmp.h>
17 #include <stdio.h>
19 void *__local_destructor_chain; /* chain of local objects that need destruction */
21 /* public data */
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 */
28 #endif
31 ** Variables passed from shared lib initialization to PyMac_AddLibResources.
33 static int library_fss_valid;
34 static FSSpec library_fss;
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).
40 OSErr pascal
41 __sinit(InitBlockPtr data)
43 if ( data == nil ) return noErr;
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;
51 return noErr;
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.
59 void
60 PyMac_AddLibResources()
62 OSErr err;
63 short fd, curfd;
65 if ( !library_fss_valid )
66 return;
67 fd = FSpOpenResFile(&library_fss, fsRdPerm);