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 | fb106c8 | 2000-08-17 20:04:26 +0000 | [diff] [blame] | 51 | #if 1 || TARGET_API_MAC_CARBON |
Jack Jansen | d843a01 | 2000-08-17 20:01:24 +0000 | [diff] [blame] | 52 | GUSIwithInetSockets(); |
| 53 | #else |
Jack Jansen | 9cfce18 | 2000-05-10 15:15:54 +0000 | [diff] [blame] | 54 | GUSIwithMTInetSockets(); |
Jack Jansen | d843a01 | 2000-08-17 20:01:24 +0000 | [diff] [blame] | 55 | #endif |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 56 | #ifdef GUSISetupFactories_EndHook |
| 57 | GUSISetupFactories_EndHook |
| 58 | #endif |
| 59 | } |
| 60 | |
| 61 | /* Declarations of File Devices */ |
| 62 | |
| 63 | __BEGIN_DECLS |
| 64 | void GUSIwithDConSockets(); |
| 65 | void GUSIwithNullSockets(); |
| 66 | void GUSISetupDevices(); |
| 67 | __END_DECLS |
| 68 | |
| 69 | /* Configure File Devices */ |
| 70 | |
| 71 | void GUSISetupDevices() |
| 72 | { |
| 73 | #ifdef GUSISetupDevices_BeginHook |
| 74 | GUSISetupDevices_BeginHook |
| 75 | #endif |
| 76 | #ifdef GUSISetupDevices_EndHook |
| 77 | GUSISetupDevices_EndHook |
| 78 | #endif |
| 79 | } |
| 80 | |
| 81 | #ifndef __cplusplus |
| 82 | #error GUSISetupConfig() needs to be written in C++ |
| 83 | #endif |
| 84 | |
| 85 | GUSIConfiguration::FileSuffix sSuffices[] = { |
| 86 | "", '????', '????' |
| 87 | }; |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 88 | extern "C" void GUSISetupConfig() |
| 89 | { |
Jack Jansen | ee08104 | 2000-04-21 23:53:37 +0000 | [diff] [blame] | 90 | Handle h; |
| 91 | short oldrh, prefrh = -1; |
| 92 | short resource_id = GUSIConfiguration::kNoResource; |
| 93 | |
| 94 | oldrh = CurResFile(); |
| 95 | |
| 96 | /* Try override from the application resource fork */ |
| 97 | UseResFile(PyMac_AppRefNum); |
| 98 | h = Get1Resource('GU\267I', GUSIOPTIONSOVERRIDE_ID); |
| 99 | if ( h ) { |
| 100 | resource_id = GUSIOPTIONSOVERRIDE_ID; |
| 101 | } else { |
| 102 | /* Next try normal resource from preference file */ |
| 103 | prefrh = PyMac_OpenPrefFile(); |
| 104 | h = Get1Resource('GU\267I', GUSIOPTIONS_ID); |
| 105 | if ( h ) { |
| 106 | resource_id = GUSIOPTIONS_ID; |
| 107 | } else { |
| 108 | /* Finally try normal resource from application */ |
| 109 | if ( prefrh != -1 ) { |
| 110 | CloseResFile(prefrh); |
| 111 | prefrh = -1; |
| 112 | } |
| 113 | resource_id = GUSIOPTIONS_ID; |
| 114 | } |
| 115 | } |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 116 | |
Jack Jansen | ee08104 | 2000-04-21 23:53:37 +0000 | [diff] [blame] | 117 | /* Now we have the right resource file topmost and the id. Init GUSI. */ |
| 118 | GUSIConfiguration * config = |
| 119 | GUSIConfiguration::CreateInstance(resource_id); |
| 120 | |
| 121 | /* Finally restore the old resource file */ |
| 122 | if ( prefrh != -1) CloseResFile(prefrh); |
| 123 | UseResFile(oldrh); |
| 124 | |
Jack Jansen | d843a01 | 2000-08-17 20:01:24 +0000 | [diff] [blame] | 125 | config->ConfigureDefaultTypeCreator('TEXT', 'R*ch'); |
| 126 | #if 0 |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 127 | config->ConfigureSuffices( |
| 128 | sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices); |
Jack Jansen | d843a01 | 2000-08-17 20:01:24 +0000 | [diff] [blame] | 129 | #endif |
Jack Jansen | 2d1306b | 2000-04-07 09:10:49 +0000 | [diff] [blame] | 130 | config->ConfigureAutoInitGraf(false); |
| 131 | config->ConfigureAutoSpin(false); |
| 132 | config->ConfigureHandleAppleEvents(false); |
| 133 | config->ConfigureSigInt(false); |
| 134 | config->ConfigureSigPipe(true); |
| 135 | |
| 136 | GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin); |
| 137 | |
| 138 | } |
| 139 | |
| 140 | /**************** END GUSI CONFIGURATION *************************/ |