Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Generated with the GUSIConfig application and then hand-modified by jack. |
| 3 | */ |
| 4 | |
| 5 | #define GUSI_SOURCE |
| 6 | #include <GUSIConfig.h> |
| 7 | #include <sys/cdefs.h> |
Jack Jansen | ee08104 | 2000-04-21 23:53:37 +0000 | [diff] [blame] | 8 | #include <Resources.h> |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 9 | |
| 10 | #include "Python.h" |
| 11 | #include "macglue.h" |
Jack Jansen | ee08104 | 2000-04-21 23:53:37 +0000 | [diff] [blame] | 12 | #include "pythonresources.h" |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 13 | |
| 14 | static void |
| 15 | PyMac_GUSISpin(bool wait) |
| 16 | { |
| 17 | static Boolean inForeground = true; |
| 18 | int maxsleep = 6; /* 6 ticks is "normal" sleeptime */ |
| 19 | |
| 20 | if (PyMac_ConsoleIsDead) return; |
| 21 | |
| 22 | if ( !wait ) |
| 23 | maxsleep = 0; |
| 24 | |
| 25 | PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */ |
| 26 | } |
| 27 | |
| 28 | |
| 29 | /* Declarations of Socket Factories */ |
| 30 | |
| 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 |
| 43 | |
| 44 | /* Configure Socket Factories */ |
| 45 | |
| 46 | void GUSISetupFactories() |
| 47 | { |
| 48 | #ifdef GUSISetupFactories_BeginHook |
| 49 | GUSISetupFactories_BeginHook |
| 50 | #endif |
Jack Jansen | 9cfce18 | 2000-05-10 15:15:54 +0000 | [diff] [blame^] | 51 | // GUSIwithInetSockets(); |
| 52 | GUSIwithMTInetSockets(); |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 53 | #ifdef GUSISetupFactories_EndHook |
| 54 | GUSISetupFactories_EndHook |
| 55 | #endif |
| 56 | } |
| 57 | |
| 58 | /* Declarations of File Devices */ |
| 59 | |
| 60 | __BEGIN_DECLS |
| 61 | void GUSIwithDConSockets(); |
| 62 | void GUSIwithNullSockets(); |
| 63 | void GUSISetupDevices(); |
| 64 | __END_DECLS |
| 65 | |
| 66 | /* Configure File Devices */ |
| 67 | |
| 68 | void GUSISetupDevices() |
| 69 | { |
| 70 | #ifdef GUSISetupDevices_BeginHook |
| 71 | GUSISetupDevices_BeginHook |
| 72 | #endif |
| 73 | #ifdef GUSISetupDevices_EndHook |
| 74 | GUSISetupDevices_EndHook |
| 75 | #endif |
| 76 | } |
| 77 | |
| 78 | #ifndef __cplusplus |
| 79 | #error GUSISetupConfig() needs to be written in C++ |
| 80 | #endif |
| 81 | |
| 82 | GUSIConfiguration::FileSuffix sSuffices[] = { |
| 83 | "", '????', '????' |
| 84 | }; |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 85 | extern "C" void GUSISetupConfig() |
| 86 | { |
Jack Jansen | ee08104 | 2000-04-21 23:53:37 +0000 | [diff] [blame] | 87 | Handle h; |
| 88 | short oldrh, prefrh = -1; |
| 89 | short resource_id = GUSIConfiguration::kNoResource; |
| 90 | |
| 91 | oldrh = CurResFile(); |
| 92 | |
| 93 | /* Try override from the application resource fork */ |
| 94 | UseResFile(PyMac_AppRefNum); |
| 95 | h = Get1Resource('GU\267I', GUSIOPTIONSOVERRIDE_ID); |
| 96 | if ( h ) { |
| 97 | resource_id = GUSIOPTIONSOVERRIDE_ID; |
| 98 | } else { |
| 99 | /* Next try normal resource from preference file */ |
| 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; |
| 109 | } |
| 110 | resource_id = GUSIOPTIONS_ID; |
| 111 | } |
| 112 | } |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 113 | |
Jack Jansen | ee08104 | 2000-04-21 23:53:37 +0000 | [diff] [blame] | 114 | /* Now we have the right resource file topmost and the id. Init GUSI. */ |
| 115 | GUSIConfiguration * config = |
| 116 | GUSIConfiguration::CreateInstance(resource_id); |
| 117 | |
| 118 | /* Finally restore the old resource file */ |
| 119 | if ( prefrh != -1) CloseResFile(prefrh); |
| 120 | UseResFile(oldrh); |
| 121 | |
| 122 | config->ConfigureDefaultTypeCreator('ttxt', 'TEXT'); |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 123 | config->ConfigureSuffices( |
| 124 | sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices); |
| 125 | config->ConfigureAutoInitGraf(false); |
| 126 | config->ConfigureAutoSpin(false); |
| 127 | config->ConfigureHandleAppleEvents(false); |
| 128 | config->ConfigureSigInt(false); |
| 129 | config->ConfigureSigPipe(true); |
| 130 | |
| 131 | GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin); |
| 132 | |
| 133 | } |
| 134 | |
| 135 | /**************** END GUSI CONFIGURATION *************************/ |