py-cvs-rel2_1 (Rev 1.2) merge
[python/dscho.git] / Mac / Python / gusiconfig.cpp
blobec6b57d5786fde33866109cc22b392e156de1073
1 /*
2 * Generated with the GUSIConfig application and then hand-modified by jack.
3 */
5 #define GUSI_SOURCE
6 #include <GUSIConfig.h>
7 #include <sys/cdefs.h>
8 #include <Resources.h>
10 #include "Python.h"
11 #include "macglue.h"
12 #include "pythonresources.h"
14 static void
15 PyMac_GUSISpin(bool wait)
17 static Boolean inForeground = true;
18 int maxsleep = 6; /* 6 ticks is "normal" sleeptime */
20 if (PyMac_ConsoleIsDead) return;
22 if ( !wait )
23 maxsleep = 0;
25 PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */
29 /* Declarations of Socket Factories */
31 __BEGIN_DECLS
32 void GUSIwithInetSockets();
33 void GUSIwithLocalSockets();
34 void GUSIwithMTInetSockets();
35 void GUSIwithMTTcpSockets();
36 void GUSIwithMTUdpSockets();
37 void GUSIwithOTInetSockets();
38 void GUSIwithOTTcpSockets();
39 void GUSIwithOTUdpSockets();
40 void GUSIwithPPCSockets();
41 void GUSISetupFactories();
42 __END_DECLS
44 /* Configure Socket Factories */
46 void GUSISetupFactories()
48 #ifdef GUSISetupFactories_BeginHook
49 GUSISetupFactories_BeginHook
50 #endif
51 GUSIwithInetSockets();
52 #ifdef GUSISetupFactories_EndHook
53 GUSISetupFactories_EndHook
54 #endif
57 /* Declarations of File Devices */
59 __BEGIN_DECLS
60 void GUSIwithDConSockets();
61 void GUSIwithNullSockets();
62 void GUSISetupDevices();
63 __END_DECLS
65 /* Configure File Devices */
67 void GUSISetupDevices()
69 #ifdef GUSISetupDevices_BeginHook
70 GUSISetupDevices_BeginHook
71 #endif
72 #ifdef GUSISetupDevices_EndHook
73 GUSISetupDevices_EndHook
74 #endif
77 #ifndef __cplusplus
78 #error GUSISetupConfig() needs to be written in C++
79 #endif
81 GUSIConfiguration::FileSuffix sSuffices[] = {
82 "", '????', '????'
84 extern "C" void GUSISetupConfig()
86 Handle h;
87 short oldrh, prefrh = -1;
88 short resource_id = GUSIConfiguration::kNoResource;
90 oldrh = CurResFile();
92 /* Try override from the application resource fork */
93 UseResFile(PyMac_AppRefNum);
94 h = Get1Resource('GU\267I', GUSIOPTIONSOVERRIDE_ID);
95 if ( h ) {
96 resource_id = GUSIOPTIONSOVERRIDE_ID;
97 } else {
98 /* Next try normal resource from preference file */
99 UseResFile(oldrh);
100 prefrh = PyMac_OpenPrefFile();
101 h = Get1Resource('GU\267I', GUSIOPTIONS_ID);
102 if ( h ) {
103 resource_id = GUSIOPTIONS_ID;
104 } else {
105 /* Finally try normal resource from application */
106 if ( prefrh != -1 ) {
107 CloseResFile(prefrh);
108 prefrh = -1;
110 resource_id = GUSIOPTIONS_ID;
114 /* Now we have the right resource file topmost and the id. Init GUSI. */
115 GUSIConfiguration * config =
116 GUSIConfiguration::CreateInstance(resource_id);
118 /* Finally restore the old resource file */
119 if ( prefrh != -1) CloseResFile(prefrh);
120 UseResFile(oldrh);
122 config->ConfigureDefaultTypeCreator('TEXT', 'R*ch');
123 #if 0
124 config->ConfigureSuffices(
125 sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices);
126 #endif
127 config->ConfigureAutoInitGraf(false);
128 config->ConfigureAutoSpin(false);
129 config->ConfigureHandleAppleEvents(false);
130 config->ConfigureSigInt(false);
131 config->ConfigureSigPipe(true);
133 GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin);
137 /**************** END GUSI CONFIGURATION *************************/