annotate Mac/Python/gusiconfig.cpp @ 13605:dc17ef1a7613 legacy-trunk

include macdefs.h for declaration of getwd, if non-gusi python.
author Jack Jansen <jack.jansen@cwi.nl>
date Fri, 14 Jul 2000 22:16:01 +0000
parents a8afefc4fced
children ae228a64293e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
1 /*
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
2 * Generated with the GUSIConfig application and then hand-modified by jack.
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
3 */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
4
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
5 #define GUSI_SOURCE
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
6 #include <GUSIConfig.h>
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
7 #include <sys/cdefs.h>
12446
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
8 #include <Resources.h>
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
9
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
10 #include "Python.h"
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
11 #include "macglue.h"
12446
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
12 #include "pythonresources.h"
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
13
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
14 static void
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
15 PyMac_GUSISpin(bool wait)
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
16 {
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
17 static Boolean inForeground = true;
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
18 int maxsleep = 6; /* 6 ticks is "normal" sleeptime */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
19
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
20 if (PyMac_ConsoleIsDead) return;
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
21
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
22 if ( !wait )
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
23 maxsleep = 0;
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
24
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
25 PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
26 }
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
27
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
28
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
29 /* Declarations of Socket Factories */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
30
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
31 __BEGIN_DECLS
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
32 void GUSIwithInetSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
33 void GUSIwithLocalSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
34 void GUSIwithMTInetSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
35 void GUSIwithMTTcpSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
36 void GUSIwithMTUdpSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
37 void GUSIwithOTInetSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
38 void GUSIwithOTTcpSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
39 void GUSIwithOTUdpSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
40 void GUSIwithPPCSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
41 void GUSISetupFactories();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
42 __END_DECLS
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
43
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
44 /* Configure Socket Factories */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
45
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
46 void GUSISetupFactories()
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
47 {
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
48 #ifdef GUSISetupFactories_BeginHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
49 GUSISetupFactories_BeginHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
50 #endif
12654
6b143ca4fd7f GUSI 2.0.5 has a non-functional getsockname() if you use Open Transport. For now the workaround is to only enable MacTCP sockets.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12446
diff changeset
51 // GUSIwithInetSockets();
6b143ca4fd7f GUSI 2.0.5 has a non-functional getsockname() if you use Open Transport. For now the workaround is to only enable MacTCP sockets.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12446
diff changeset
52 GUSIwithMTInetSockets();
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
53 #ifdef GUSISetupFactories_EndHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
54 GUSISetupFactories_EndHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
55 #endif
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
56 }
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
57
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
58 /* Declarations of File Devices */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
59
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
60 __BEGIN_DECLS
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
61 void GUSIwithDConSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
62 void GUSIwithNullSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
63 void GUSISetupDevices();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
64 __END_DECLS
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
65
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
66 /* Configure File Devices */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
67
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
68 void GUSISetupDevices()
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
69 {
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
70 #ifdef GUSISetupDevices_BeginHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
71 GUSISetupDevices_BeginHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
72 #endif
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
73 #ifdef GUSISetupDevices_EndHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
74 GUSISetupDevices_EndHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
75 #endif
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
76 }
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
77
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
78 #ifndef __cplusplus
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
79 #error GUSISetupConfig() needs to be written in C++
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
80 #endif
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
81
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
82 GUSIConfiguration::FileSuffix sSuffices[] = {
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
83 "", '????', '????'
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
84 };
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
85 extern "C" void GUSISetupConfig()
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
86 {
12446
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
87 Handle h;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
88 short oldrh, prefrh = -1;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
89 short resource_id = GUSIConfiguration::kNoResource;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
90
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
91 oldrh = CurResFile();
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
92
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
93 /* Try override from the application resource fork */
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
94 UseResFile(PyMac_AppRefNum);
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
95 h = Get1Resource('GU\267I', GUSIOPTIONSOVERRIDE_ID);
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
96 if ( h ) {
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
97 resource_id = GUSIOPTIONSOVERRIDE_ID;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
98 } else {
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
99 /* Next try normal resource from preference file */
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
100 prefrh = PyMac_OpenPrefFile();
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
101 h = Get1Resource('GU\267I', GUSIOPTIONS_ID);
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
102 if ( h ) {
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
103 resource_id = GUSIOPTIONS_ID;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
104 } else {
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
105 /* Finally try normal resource from application */
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
106 if ( prefrh != -1 ) {
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
107 CloseResFile(prefrh);
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
108 prefrh = -1;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
109 }
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
110 resource_id = GUSIOPTIONS_ID;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
111 }
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
112 }
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
113
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
114 /* Now we have the right resource file topmost and the id. Init GUSI. */
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
115 GUSIConfiguration * config =
12446
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
116 GUSIConfiguration::CreateInstance(resource_id);
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
117
12446
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
118 /* Finally restore the old resource file */
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
119 if ( prefrh != -1) CloseResFile(prefrh);
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
120 UseResFile(oldrh);
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
121
12922
a8afefc4fced Oops, default type and creator were reversed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12654
diff changeset
122 config->ConfigureDefaultTypeCreator('TEXT', 'ttxt');
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
123 config->ConfigureSuffices(
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
124 sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
125 config->ConfigureAutoInitGraf(false);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
126 config->ConfigureAutoSpin(false);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
127 config->ConfigureHandleAppleEvents(false);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
128 config->ConfigureSigInt(false);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
129 config->ConfigureSigPipe(true);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
130
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
131 GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
132
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
133 }
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
134
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
135 /**************** END GUSI CONFIGURATION *************************/