blob: 943a0a674b47f538f5b671a80ab40052b5ab6673 [file] [log] [blame]
Jack Jansen2d1306b2000-04-07 09:10:49 +00001/*
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 Jansenee081042000-04-21 23:53:37 +00008#include <Resources.h>
Jack Jansen2d1306b2000-04-07 09:10:49 +00009
10#include "Python.h"
11#include "macglue.h"
Jack Jansenee081042000-04-21 23:53:37 +000012#include "pythonresources.h"
Jack Jansen2d1306b2000-04-07 09:10:49 +000013
14static void
15PyMac_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
32void GUSIwithInetSockets();
33void GUSIwithLocalSockets();
34void GUSIwithMTInetSockets();
35void GUSIwithMTTcpSockets();
36void GUSIwithMTUdpSockets();
37void GUSIwithOTInetSockets();
38void GUSIwithOTTcpSockets();
39void GUSIwithOTUdpSockets();
40void GUSIwithPPCSockets();
41void GUSISetupFactories();
42__END_DECLS
43
44/* Configure Socket Factories */
45
46void GUSISetupFactories()
47{
48#ifdef GUSISetupFactories_BeginHook
49 GUSISetupFactories_BeginHook
50#endif
51 GUSIwithInetSockets();
52#ifdef GUSISetupFactories_EndHook
53 GUSISetupFactories_EndHook
54#endif
55}
56
57/* Declarations of File Devices */
58
59__BEGIN_DECLS
60void GUSIwithDConSockets();
61void GUSIwithNullSockets();
62void GUSISetupDevices();
63__END_DECLS
64
65/* Configure File Devices */
66
67void GUSISetupDevices()
68{
69#ifdef GUSISetupDevices_BeginHook
70 GUSISetupDevices_BeginHook
71#endif
72#ifdef GUSISetupDevices_EndHook
73 GUSISetupDevices_EndHook
74#endif
75}
76
77#ifndef __cplusplus
78#error GUSISetupConfig() needs to be written in C++
79#endif
80
81GUSIConfiguration::FileSuffix sSuffices[] = {
82 "", '????', '????'
83};
Jack Jansen2d1306b2000-04-07 09:10:49 +000084extern "C" void GUSISetupConfig()
85{
Jack Jansenee081042000-04-21 23:53:37 +000086 Handle h;
87 short oldrh, prefrh = -1;
88 short resource_id = GUSIConfiguration::kNoResource;
89
90 oldrh = CurResFile();
91
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 prefrh = PyMac_OpenPrefFile();
100 h = Get1Resource('GU\267I', GUSIOPTIONS_ID);
101 if ( h ) {
102 resource_id = GUSIOPTIONS_ID;
103 } else {
104 /* Finally try normal resource from application */
105 if ( prefrh != -1 ) {
106 CloseResFile(prefrh);
107 prefrh = -1;
108 }
109 resource_id = GUSIOPTIONS_ID;
110 }
111 }
Jack Jansen2d1306b2000-04-07 09:10:49 +0000112
Jack Jansenee081042000-04-21 23:53:37 +0000113 /* Now we have the right resource file topmost and the id. Init GUSI. */
114 GUSIConfiguration * config =
115 GUSIConfiguration::CreateInstance(resource_id);
116
117 /* Finally restore the old resource file */
118 if ( prefrh != -1) CloseResFile(prefrh);
119 UseResFile(oldrh);
120
121 config->ConfigureDefaultTypeCreator('ttxt', 'TEXT');
Jack Jansen2d1306b2000-04-07 09:10:49 +0000122 config->ConfigureSuffices(
123 sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices);
124 config->ConfigureAutoInitGraf(false);
125 config->ConfigureAutoSpin(false);
126 config->ConfigureHandleAppleEvents(false);
127 config->ConfigureSigInt(false);
128 config->ConfigureSigPipe(true);
129
130 GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin);
131
132}
133
134/**************** END GUSI CONFIGURATION *************************/