annotate Mac/Python/macmain.c @ 12593:eaee924efb19 legacy-trunk

Removed string-exception preference, added tabcheck and NavService preference, upped version number.
author Jack Jansen <jack.jansen@cwi.nl>
date Fri, 05 May 2000 23:11:14 +0000
parents 51c0c3b6d919
children c2a0f2a81fa8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1811
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /***********************************************************
5079
d6b292a33cfe Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents: 4962
diff changeset
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
2091
b4d982c648bb 1995 copyright
Guido van Rossum <guido@python.org>
parents: 2031
diff changeset
3 The Netherlands.
1811
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 All Rights Reserved
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 documentation for any purpose and without fee is hereby granted,
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 provided that the above copyright notice appear in all copies and that
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 both that copyright notice and this permission notice appear in
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 supporting documentation, and that the names of Stichting Mathematisch
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 Centrum or CWI not be used in advertising or publicity pertaining to
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 distribution of the software without specific, written prior permission.
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
14
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 ******************************************************************/
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
25 /* Python interpreter main program */
1811
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
26
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
27 #include "Python.h"
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
28 #include "pythonresources.h"
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
29 #include "import.h"
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
30 #include "marshal.h"
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4017
diff changeset
31 #include "macglue.h"
2144
0e60cd207adb must include rename2.h
Guido van Rossum <guido@python.org>
parents: 2091
diff changeset
32
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
33 #include <Memory.h>
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
34 #include <Resources.h>
1811
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 #include <stdio.h>
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
36 #include <Events.h>
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
37 #include <Windows.h>
3442
066a8ae4d406 Added missing include of Fonts.h
Jack Jansen <jack.jansen@cwi.nl>
parents: 3433
diff changeset
38 #include <Fonts.h>
6293
6c0a2658a156 Added old-exception and no-site-python options and balloon help
Jack Jansen <jack.jansen@cwi.nl>
parents: 6277
diff changeset
39 #include <Balloons.h>
11529
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
40 #ifdef USE_APPEARANCE
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
41 #include <Gestalt.h>
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
42 #include <Appearance.h>
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
43 #endif /* USE_APPEARANCE */
2277
df7e26b5c918 Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents: 2226
diff changeset
44 #ifdef __MWERKS__
df7e26b5c918 Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents: 2226
diff changeset
45 #include <SIOUX.h>
3247
20d74fa3b50b For MW Python, update titlebar of window when python exits.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3236
diff changeset
46 #define USE_SIOUX
4911
21878c849626 Added profiler initialization/finalization code (if __profile__ is defined)
Jack Jansen <jack.jansen@cwi.nl>
parents: 4249
diff changeset
47 #if __profile__ == 1
21878c849626 Added profiler initialization/finalization code (if __profile__ is defined)
Jack Jansen <jack.jansen@cwi.nl>
parents: 4249
diff changeset
48 #include <profiler.h>
21878c849626 Added profiler initialization/finalization code (if __profile__ is defined)
Jack Jansen <jack.jansen@cwi.nl>
parents: 4249
diff changeset
49 #endif
2277
df7e26b5c918 Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents: 2226
diff changeset
50 #endif
df7e26b5c918 Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents: 2226
diff changeset
51
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
52 #ifdef THINK_C
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
53 #include <console.h>
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
54 #endif
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
55
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
56 #define STARTUP "PythonStartup"
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
57
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
58 extern int Py_DebugFlag; /* For parser.c, declared in pythonrun.c */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
59 extern int Py_VerboseFlag; /* For import.c, declared in pythonrun.c */
4228
84444ea3f5f6 - Rationalized override preferences support, by remembering
Jack Jansen <jack.jansen@cwi.nl>
parents: 4215
diff changeset
60 short PyMac_AppRefNum; /* RefNum of application resource fork */
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
61
3930
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
62 /* For Py_GetArgcArgv(); set by main() */
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
63 static char **orig_argv;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
64 static int orig_argc;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
65
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
66 PyMac_PrefRecord options;
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
67
4017
5dc8c042905b Guido: added some void's to declarations
Jack Jansen <jack.jansen@cwi.nl>
parents: 3930
diff changeset
68 static void Py_Main Py_PROTO((int, char **)); /* Forward */
5dc8c042905b Guido: added some void's to declarations
Jack Jansen <jack.jansen@cwi.nl>
parents: 3930
diff changeset
69 void PyMac_Exit Py_PROTO((int)); /* Forward */
5dc8c042905b Guido: added some void's to declarations
Jack Jansen <jack.jansen@cwi.nl>
parents: 3930
diff changeset
70
11529
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
71 static void init_appearance()
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
72 {
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
73 #ifdef USE_APPEARANCE
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
74 OSErr err;
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
75 SInt32 response;
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
76
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
77 err = Gestalt(gestaltAppearanceAttr,&response);
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
78 if ( err ) goto no_appearance;
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
79 if ( !(response&(1<<gestaltAppearanceExists)) ) goto no_appearance;
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
80 /* XXXX Should we check the version? Compat-mode? */
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
81 PyMac_AppearanceCompliant = 1;
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
82 no_appearance:
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
83 return;
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
84 #endif /* USE_APPEARANCE */
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
85 }
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
86 /* Initialize the Mac toolbox world */
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
87
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
88 static void
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
89 init_mac_world()
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
90 {
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
91 #ifdef THINK_C
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
92 printf("\n");
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
93 #else
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
94 MaxApplZone();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
95 InitGraf(&qd.thePort);
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
96 InitFonts();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
97 InitWindows();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
98 TEInit();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
99 InitDialogs((long)0);
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
100 InitMenus();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
101 InitCursor();
11529
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 11350
diff changeset
102 init_appearance();
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
103 #endif
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
104 }
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
105
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
106 /*
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
107 ** PyMac_InteractiveOptions - Allow user to set options if option key is pressed
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
108 */
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
109 static void
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
110 PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp)
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
111 {
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
112 KeyMap rmap;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
113 unsigned char *map;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
114 short item, type;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
115 ControlHandle handle;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
116 DialogPtr dialog;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
117 Rect rect;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
118 int old_argc = *argcp;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
119 int i;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
120
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
121 /*
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
122 ** If the preferences disallows interactive options we return,
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
123 ** similarly of <option> isn't pressed.
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
124 */
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
125 if (p->nointopt) return;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
126
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
127 GetKeys(rmap);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
128 map = (unsigned char *)rmap;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
129 if ( ( map[0x3a>>3] & (1<<(0x3a&7)) ) == 0 ) /* option key is 3a */
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
130 return;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
131
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
132 dialog = GetNewDialog(OPT_DIALOG, NULL, (WindowPtr)-1);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
133 if ( dialog == NULL ) {
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
134 printf("Option dialog not found - cannot set options\n");
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
135 return;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
136 }
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
137 SetDialogDefaultItem(dialog, OPT_OK);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
138 SetDialogCancelItem(dialog, OPT_CANCEL);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
139
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
140 /* Set default values */
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
141 #define SET_OPT_ITEM(num, var) \
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
142 GetDialogItem(dialog, (num), &type, (Handle *)&handle, &rect); \
5270
de9d0c5249b0 Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents: 5153
diff changeset
143 SetControlValue(handle, (short)p->var);
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
144
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
145 SET_OPT_ITEM(OPT_INSPECT, inspect);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
146 SET_OPT_ITEM(OPT_VERBOSE, verbose);
6293
6c0a2658a156 Added old-exception and no-site-python options and balloon help
Jack Jansen <jack.jansen@cwi.nl>
parents: 6277
diff changeset
147 SET_OPT_ITEM(OPT_OPTIMIZE, optimize);
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
148 SET_OPT_ITEM(OPT_UNBUFFERED, unbuffered);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
149 SET_OPT_ITEM(OPT_DEBUGGING, debugging);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
150 SET_OPT_ITEM(OPT_KEEPNORMAL, keep_normal);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
151 SET_OPT_ITEM(OPT_KEEPERROR, keep_error);
12593
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
152 SET_OPT_ITEM(OPT_TABWARN, tabwarn);
6293
6c0a2658a156 Added old-exception and no-site-python options and balloon help
Jack Jansen <jack.jansen@cwi.nl>
parents: 6277
diff changeset
153 SET_OPT_ITEM(OPT_NOSITE, nosite);
12593
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
154 SET_OPT_ITEM(OPT_NONAVSERV, nonavservice);
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
155 /* The rest are not settable interactively */
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
156
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
157 #undef SET_OPT_ITEM
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
158
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
159 while (1) {
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
160 handle = NULL;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
161 ModalDialog(NULL, &item);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
162 if ( item == OPT_OK )
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
163 break;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
164 if ( item == OPT_CANCEL ) {
5270
de9d0c5249b0 Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents: 5153
diff changeset
165 DisposeDialog(dialog);
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
166 exit(0);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
167 }
6293
6c0a2658a156 Added old-exception and no-site-python options and balloon help
Jack Jansen <jack.jansen@cwi.nl>
parents: 6277
diff changeset
168 if ( item == OPT_HELP ) {
6c0a2658a156 Added old-exception and no-site-python options and balloon help
Jack Jansen <jack.jansen@cwi.nl>
parents: 6277
diff changeset
169 HMSetBalloons(!HMGetBalloons());
6c0a2658a156 Added old-exception and no-site-python options and balloon help
Jack Jansen <jack.jansen@cwi.nl>
parents: 6277
diff changeset
170 }
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
171 if ( item == OPT_CMDLINE ) {
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
172 int new_argc, newer_argc;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
173 char **new_argv, **newer_argv;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
174
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
175 new_argc = ccommand(&new_argv);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
176 newer_argc = (new_argc-1) + old_argc;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
177 newer_argv = malloc((newer_argc+1)*sizeof(char *));
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
178 if( !newer_argv )
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
179 Py_FatalError("Cannot malloc argv\n");
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
180 for(i=0; i<old_argc; i++)
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
181 newer_argv[i] = (*argvp)[i];
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
182 for(i=old_argc; i<=newer_argc; i++) /* Copy the NULL too */
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
183 newer_argv[i] = new_argv[i-old_argc+1];
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
184 *argvp = newer_argv;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
185 *argcp = newer_argc;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
186
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
187 /* XXXX Is it not safe to use free() here, apparently */
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
188 }
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
189 #define OPT_ITEM(num, var) \
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
190 if ( item == (num) ) { \
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
191 p->var = !p->var; \
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
192 GetDialogItem(dialog, (num), &type, (Handle *)&handle, &rect); \
5270
de9d0c5249b0 Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents: 5153
diff changeset
193 SetControlValue(handle, (short)p->var); \
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
194 }
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
195
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
196 OPT_ITEM(OPT_INSPECT, inspect);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
197 OPT_ITEM(OPT_VERBOSE, verbose);
6293
6c0a2658a156 Added old-exception and no-site-python options and balloon help
Jack Jansen <jack.jansen@cwi.nl>
parents: 6277
diff changeset
198 OPT_ITEM(OPT_OPTIMIZE, optimize);
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
199 OPT_ITEM(OPT_UNBUFFERED, unbuffered);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
200 OPT_ITEM(OPT_DEBUGGING, debugging);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
201 OPT_ITEM(OPT_KEEPNORMAL, keep_normal);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
202 OPT_ITEM(OPT_KEEPERROR, keep_error);
12593
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
203 OPT_ITEM(OPT_TABWARN, tabwarn);
6293
6c0a2658a156 Added old-exception and no-site-python options and balloon help
Jack Jansen <jack.jansen@cwi.nl>
parents: 6277
diff changeset
204 OPT_ITEM(OPT_NOSITE, nosite);
12593
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
205 OPT_ITEM(OPT_NONAVSERV, nonavservice);
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
206
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
207 #undef OPT_ITEM
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
208 }
5270
de9d0c5249b0 Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents: 5153
diff changeset
209 DisposeDialog(dialog);
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
210 }
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
211
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
212 /*
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
213 ** Initialization code, shared by interpreter and applets
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
214 */
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
215 static void
4962
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
216 init_common(int *argcp, char ***argvp, int embedded)
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
217 {
4228
84444ea3f5f6 - Rationalized override preferences support, by remembering
Jack Jansen <jack.jansen@cwi.nl>
parents: 4215
diff changeset
218 /* Remember resource fork refnum, for later */
84444ea3f5f6 - Rationalized override preferences support, by remembering
Jack Jansen <jack.jansen@cwi.nl>
parents: 4215
diff changeset
219 PyMac_AppRefNum = CurResFile();
84444ea3f5f6 - Rationalized override preferences support, by remembering
Jack Jansen <jack.jansen@cwi.nl>
parents: 4215
diff changeset
220
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
221 /* Initialize toolboxes */
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
222 init_mac_world();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
223
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
224 #ifdef USE_MAC_SHARED_LIBRARY
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
225 /* Add the shared library to the stack of resource files */
8792
0f5e0b405bc2 Initialize the program name before adding shared library resources (Just).
Jack Jansen <jack.jansen@cwi.nl>
parents: 6444
diff changeset
226 (void)PyMac_init_process_location();
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
227 PyMac_AddLibResources();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
228 #endif
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
229
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11529
diff changeset
230 #if defined(USE_GUSI1)
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
231 /* Setup GUSI */
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
232 GUSIDefaultSetup();
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4017
diff changeset
233 PyMac_SetGUSISpin();
4228
84444ea3f5f6 - Rationalized override preferences support, by remembering
Jack Jansen <jack.jansen@cwi.nl>
parents: 4215
diff changeset
234 PyMac_SetGUSIOptions();
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11529
diff changeset
235 #endif
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11529
diff changeset
236 #if defined(USE_GUSI)
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5431
diff changeset
237 atexit(PyMac_StopGUSISpin);
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11529
diff changeset
238 #endif
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
239
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
240 #ifdef USE_SIOUX
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
241 /* Set various SIOUX flags. Some are changed later based on options */
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
242 /* SIOUXSettings.standalone = 0; /* XXXX Attempting to keep sioux from eating events */
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
243 SIOUXSettings.asktosaveonclose = 0;
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
244 SIOUXSettings.showstatusline = 0;
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
245 SIOUXSettings.tabspaces = 4;
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
246 #endif
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
247
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
248 /* Get options from preference file (or from applet resource fork) */
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
249 options.keep_error = 1; /* default-default */
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
250 PyMac_PreferenceOptions(&options);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
251
4962
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
252 if ( embedded ) {
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
253 static char *emb_argv[] = {"embedded-python", 0};
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
254
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
255 *argcp = 1;
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
256 *argvp = emb_argv;
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
257 } else {
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
258 /* Create argc/argv. Do it before we go into the options event loop. */
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
259 *argcp = PyMac_GetArgv(argvp, options.noargs);
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
260
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
261 /* Do interactive option setting, if allowed and <option> depressed */
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
262 PyMac_InteractiveOptions(&options, argcp, argvp);
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
263 }
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
264
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
265 /* Copy selected options to where the machine-independent stuff wants it */
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
266 Py_VerboseFlag = options.verbose;
5961
35e5acc6532c Adapted for 1.5a3: Py_SupressPrintingFlag is gone, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
267 /* Py_SuppressPrintingFlag = options.suppress_print; */
6293
6c0a2658a156 Added old-exception and no-site-python options and balloon help
Jack Jansen <jack.jansen@cwi.nl>
parents: 6277
diff changeset
268 Py_OptimizeFlag = options.optimize;
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
269 Py_DebugFlag = options.debugging;
6444
93c015ec2d57 Implemented nositepython and oldexceptions flags
Jack Jansen <jack.jansen@cwi.nl>
parents: 6293
diff changeset
270 Py_NoSiteFlag = options.nosite;
12593
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
271 Py_TabcheckFlag = options.tabwarn;
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
272 if ( options.noargs ) {
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
273 /* don't process events at all without the scripts permission */
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
274 PyMacSchedParams scp;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
275
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
276 PyMac_GetSchedParams(&scp);
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
277 scp.process_events = 0;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
278 /* Should we disable command-dot as well? */
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
279 PyMac_SetSchedParams(&scp);
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
280 }
6293
6c0a2658a156 Added old-exception and no-site-python options and balloon help
Jack Jansen <jack.jansen@cwi.nl>
parents: 6277
diff changeset
281 /* XXXX dispatch oldexc and nosite */
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
282
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
283 /* Set buffering */
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
284 if (options.unbuffered) {
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
285 #ifndef MPW
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
286 setbuf(stdout, (char *)NULL);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
287 setbuf(stderr, (char *)NULL);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
288 #else
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
289 /* On MPW (3.2) unbuffered seems to hang */
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
290 setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
291 setvbuf(stderr, (char *)NULL, _IOLBF, BUFSIZ);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
292 #endif
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
293 }
4911
21878c849626 Added profiler initialization/finalization code (if __profile__ is defined)
Jack Jansen <jack.jansen@cwi.nl>
parents: 4249
diff changeset
294 #if __profile__ == 1
21878c849626 Added profiler initialization/finalization code (if __profile__ is defined)
Jack Jansen <jack.jansen@cwi.nl>
parents: 4249
diff changeset
295 /* collectSummary or collectDetailed, timebase, #routines, max stack depth */
11350
678a9a79c7e8 Bigger buffer size for C profiler (if profiling is enabled).
Jack Jansen <jack.jansen@cwi.nl>
parents: 8792
diff changeset
296 ProfilerInit(collectSummary, bestTimeBase, 8000, 250);
4911
21878c849626 Added profiler initialization/finalization code (if __profile__ is defined)
Jack Jansen <jack.jansen@cwi.nl>
parents: 4249
diff changeset
297 #endif
5961
35e5acc6532c Adapted for 1.5a3: Py_SupressPrintingFlag is gone, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
298
35e5acc6532c Adapted for 1.5a3: Py_SupressPrintingFlag is gone, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
299 /* Tell the rest of python about our argc/argv */
35e5acc6532c Adapted for 1.5a3: Py_SupressPrintingFlag is gone, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
300 orig_argc = *argcp; /* For Py_GetArgcArgv() */
35e5acc6532c Adapted for 1.5a3: Py_SupressPrintingFlag is gone, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
301 orig_argv = *argvp;
35e5acc6532c Adapted for 1.5a3: Py_SupressPrintingFlag is gone, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
302 Py_SetProgramName((*argvp)[0]);
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
303 }
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
304
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
305 /*
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
306 ** Inspection mode after script/applet termination
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
307 */
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
308 static int
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
309 run_inspect()
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
310 {
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
311 int sts = 0;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
312
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
313 if (options.inspect && isatty((int)fileno(stdin)))
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
314 sts = PyRun_AnyFile(stdin, "<stdin>") != 0;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
315 return sts;
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
316 }
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
317
12593
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
318 /*
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
319 ** Import the macfsn module, which will override the Standard File
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
320 ** calls in the macfs builtin module by Navigation Services versions,
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
321 ** if available on this machine.
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
322 */
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
323 static void
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
324 PyMac_InstallNavServicesForSF()
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
325 {
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
326 if ( !options.nonavservice ) {
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
327 PyObject *m = PyImport_ImportModule("macfsn");
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
328
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
329 if ( m == NULL ) {
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
330 PySys_WriteStderr("'import macfsn' failed; ");
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
331 if (Py_VerboseFlag) {
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
332 PySys_WriteStderr("traceback:\n");
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
333 PyErr_Print();
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
334 }
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
335 else {
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
336 PySys_WriteStderr("use -v for traceback\n");
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
337 }
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
338 }
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
339 }
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
340 }
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
341
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
342 #ifdef USE_MAC_APPLET_SUPPORT
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
343 /* Applet support */
2031
1739f00ffc86 Enlarged version buffer (nobody expects the spanish inquisition:-)
Jack Jansen <jack.jansen@cwi.nl>
parents: 1821
diff changeset
344
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
345 /* Run a compiled Python Python script from 'PYC ' resource __main__ */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
346 static int
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
347 run_main_resource()
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
348 {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
349 Handle h;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
350 long size;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
351 PyObject *code;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
352 PyObject *result;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
353
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
354 h = GetNamedResource('PYC ', "\p__main__");
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
355 if (h == NULL) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
356 Alert(NOPYC_ALERT, NULL);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
357 return 1;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
358 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
359 size = GetResourceSizeOnDisk(h);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
360 HLock(h);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
361 code = PyMarshal_ReadObjectFromString(*h + 8, (int)(size - 8));
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
362 HUnlock(h);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
363 ReleaseResource(h);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
364 if (code == NULL) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
365 PyErr_Print();
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
366 return 1;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
367 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
368 result = PyImport_ExecCodeModule("__main__", code);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
369 Py_DECREF(code);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
370 if (result == NULL) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
371 PyErr_Print();
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
372 return 1;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
373 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
374 Py_DECREF(result);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
375 return 0;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
376 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
377
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
378 /* Initialization sequence for applets */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
379 void
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
380 PyMac_InitApplet()
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
381 {
1811
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
382 int argc;
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
383 char **argv;
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
384 int err;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
385
4962
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
386 init_common(&argc, &argv, 0);
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
387
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
388 Py_Initialize();
12593
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
389 PyMac_InstallNavServicesForSF();
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
390 PySys_SetArgv(argc, argv);
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
391
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
392 err = run_main_resource();
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
393
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
394 err = (run_inspect() || err);
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
395
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
396 fflush(stderr);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
397 fflush(stdout);
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
398 PyMac_Exit(err);
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
399 /* XXX Should we bother to Py_Exit(sts)? */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
400 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
401
4962
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
402 /*
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
403 ** Hook for embedding python.
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
404 */
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
405 void
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
406 PyMac_Initialize()
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
407 {
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
408 int argc;
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
409 char **argv;
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
410
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
411 init_common(&argc, &argv, 1);
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
412 Py_Initialize();
12593
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
413 PyMac_InstallNavServicesForSF();
4962
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
414 PySys_SetArgv(argc, argv);
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
415 }
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
416
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
417 #endif /* USE_MAC_APPLET_SUPPORT */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
418
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
419 /* For normal application */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
420 void
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
421 PyMac_InitApplication()
1811
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
422 {
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
423 int argc;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
424 char **argv;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
425
4962
765d962f4449 Added PyMac_Initialize() routine, to be used by embedding programs (in
Jack Jansen <jack.jansen@cwi.nl>
parents: 4911
diff changeset
426 init_common(&argc, &argv, 0);
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
427
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
428 if ( argc > 1 ) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
429 /* We're running a script. Attempt to change current directory */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
430 char curwd[256], *endp;
2313
ff72a5f9a4ee Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents: 2277
diff changeset
431
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
432 strcpy(curwd, argv[1]);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
433 endp = strrchr(curwd, ':');
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
434 if ( endp && endp > curwd ) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
435 *endp = '\0';
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
436
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
437 chdir(curwd);
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11529
diff changeset
438 #ifdef USE_GUSI1
3433
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3422
diff changeset
439 /* Change MacOS's idea of wd too */
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3422
diff changeset
440 PyMac_FixGUSIcd();
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3422
diff changeset
441 #endif
2313
ff72a5f9a4ee Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents: 2277
diff changeset
442 }
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
443 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
444 Py_Main(argc, argv);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
445 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
446
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
447 /* Main program */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
448
4017
5dc8c042905b Guido: added some void's to declarations
Jack Jansen <jack.jansen@cwi.nl>
parents: 3930
diff changeset
449 static void
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
450 Py_Main(argc, argv)
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
451 int argc;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
452 char **argv;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
453 {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
454 int sts;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
455 char *command = NULL;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
456 char *filename = NULL;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
457 FILE *fp = stdin;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
458
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
459 filename = argv[1];
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
460
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
461 if (Py_VerboseFlag ||
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
462 command == NULL && filename == NULL && isatty((int)fileno(fp)))
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
463 fprintf(stderr, "Python %s\n%s\n",
3750
a22438e94fe9 Old names changed to Py_GetCopyright, etc.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3477
diff changeset
464 Py_GetVersion(), Py_GetCopyright());
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
465
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
466 if (filename != NULL) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
467 if ((fp = fopen(filename, "r")) == NULL) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
468 fprintf(stderr, "%s: can't open file '%s'\n",
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
469 argv[0], filename);
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
470 PyMac_Exit(2);
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
471 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
472 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
473
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
474 /* We initialize the menubar here, hoping SIOUX is initialized by now */
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4197
diff changeset
475 PyMac_InitMenuBar();
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4197
diff changeset
476
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
477 Py_Initialize();
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
478
12593
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
479 PyMac_InstallNavServicesForSF();
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
480
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
481 PySys_SetArgv(argc-1, argv+1);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
482
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
483 if (filename == NULL && isatty((int)fileno(fp))) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
484 FILE *fp = fopen(STARTUP, "r");
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
485 if (fp != NULL) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
486 (void) PyRun_SimpleFile(fp, STARTUP);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
487 PyErr_Clear();
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
488 fclose(fp);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
489 }
1811
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
490 }
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
491 sts = PyRun_AnyFile(
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
492 fp, filename == NULL ? "<stdin>" : filename) != 0;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
493 if (filename != NULL)
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
494 fclose(fp);
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
495
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
496 if ( filename != NULL || command != NULL )
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
497 sts = (run_inspect() || sts);
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
498
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
499 Py_Exit(sts);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
500 /*NOTREACHED*/
1811
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
501 }
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
502
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
503 /*
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
504 ** Terminate application
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
505 */
4017
5dc8c042905b Guido: added some void's to declarations
Jack Jansen <jack.jansen@cwi.nl>
parents: 3930
diff changeset
506 void
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
507 PyMac_Exit(status)
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
508 int status;
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
509 {
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
510 int keep;
4911
21878c849626 Added profiler initialization/finalization code (if __profile__ is defined)
Jack Jansen <jack.jansen@cwi.nl>
parents: 4249
diff changeset
511
21878c849626 Added profiler initialization/finalization code (if __profile__ is defined)
Jack Jansen <jack.jansen@cwi.nl>
parents: 4249
diff changeset
512 #if __profile__ == 1
21878c849626 Added profiler initialization/finalization code (if __profile__ is defined)
Jack Jansen <jack.jansen@cwi.nl>
parents: 4249
diff changeset
513 ProfilerDump("\pPython Profiler Results");
21878c849626 Added profiler initialization/finalization code (if __profile__ is defined)
Jack Jansen <jack.jansen@cwi.nl>
parents: 4249
diff changeset
514 ProfilerTerm();
21878c849626 Added profiler initialization/finalization code (if __profile__ is defined)
Jack Jansen <jack.jansen@cwi.nl>
parents: 4249
diff changeset
515 #endif
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
516 if ( status )
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
517 keep = options.keep_error;
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
518 else
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4228
diff changeset
519 keep = options.keep_normal;
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
520
3247
20d74fa3b50b For MW Python, update titlebar of window when python exits.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3236
diff changeset
521 #ifdef USE_SIOUX
20d74fa3b50b For MW Python, update titlebar of window when python exits.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3236
diff changeset
522 if (keep) {
20d74fa3b50b For MW Python, update titlebar of window when python exits.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3236
diff changeset
523 SIOUXSettings.standalone = 1;
20d74fa3b50b For MW Python, update titlebar of window when python exits.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3236
diff changeset
524 SIOUXSettings.autocloseonquit = 0;
3477
a4f01d43dad6 Replaced non-ascii chars by backslash escapes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3465
diff changeset
525 SIOUXSetTitle("\p\307terminated\310");
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
526 PyMac_RestoreMenuBar();
5431
a56b44b35505 Workaround for bug in MSL and CWGUSI interaction that stopped the
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
527 #ifdef USE_MSL
a56b44b35505 Workaround for bug in MSL and CWGUSI interaction that stopped the
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
528 /*
a56b44b35505 Workaround for bug in MSL and CWGUSI interaction that stopped the
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
529 ** Temporary workaround: autocloseonquit clearing does not
a56b44b35505 Workaround for bug in MSL and CWGUSI interaction that stopped the
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
530 ** currently work for the MSL/GUSI combo.
a56b44b35505 Workaround for bug in MSL and CWGUSI interaction that stopped the
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
531 */
a56b44b35505 Workaround for bug in MSL and CWGUSI interaction that stopped the
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
532 while(getchar() > 0);
a56b44b35505 Workaround for bug in MSL and CWGUSI interaction that stopped the
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
533 #endif
3247
20d74fa3b50b For MW Python, update titlebar of window when python exits.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3236
diff changeset
534 }
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
535 else
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
536 SIOUXSettings.autocloseonquit = 1;
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4017
diff changeset
537 #endif /* USE_SIOUX */
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
538 #ifdef THINK_C
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
539 console_options.pause_atexit = keep;
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
540 #endif
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
541
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
542 exit(status);
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
543 }
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
544
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
545 /* Return the program name -- some code out there needs this. */
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5431
diff changeset
546 char *
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5431
diff changeset
547 Py_GetProgramFullPath()
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5431
diff changeset
548 {
5961
35e5acc6532c Adapted for 1.5a3: Py_SupressPrintingFlag is gone, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
549 return orig_argv[0];
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5431
diff changeset
550 }
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5431
diff changeset
551
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
552
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
553 /* Make the *original* argc/argv available to other modules.
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
554 This is rare, but it is needed by the secureware extension. */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
555
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
556 void
3930
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
557 Py_GetArgcArgv(argc,argv)
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
558 int *argc;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
559 char ***argv;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
560 {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
561 *argc = orig_argc;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
562 *argv = orig_argv;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
563 }
3930
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
564
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
565 /* More cruft that shouldn't really be here, used in sysmodule.c */
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
566
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
567 char *
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
568 Py_GetPrefix()
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
569 {
6277
bb5472fb4885 sys.prefix and sys.exec_prefix are now set correctly.
Jack Jansen <jack.jansen@cwi.nl>
parents: 5961
diff changeset
570 return PyMac_GetPythonDir();
3930
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
571 }
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
572
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
573 char *
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
574 Py_GetExecPrefix()
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
575 {
6277
bb5472fb4885 sys.prefix and sys.exec_prefix are now set correctly.
Jack Jansen <jack.jansen@cwi.nl>
parents: 5961
diff changeset
576 return PyMac_GetPythonDir();
3930
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
577 }