annotate Mac/Python/macmain.c @ 3930:52c19ee83a6b legacy-trunk

Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
author Jack Jansen <jack.jansen@cwi.nl>
date Fri, 02 Aug 1996 15:16:16 +0000
parents a22438e94fe9
children 5dc8c042905b
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 /***********************************************************
2091
b4d982c648bb 1995 copyright
Guido van Rossum <guido@python.org>
parents: 2031
diff changeset
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
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"
2144
0e60cd207adb must include rename2.h
Guido van Rossum <guido@python.org>
parents: 2091
diff changeset
31
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
32 #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
33 #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
34 #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
35 #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
36 #include <Windows.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 <Desk.h>
3442
066a8ae4d406 Added missing include of Fonts.h
Jack Jansen <jack.jansen@cwi.nl>
parents: 3433
diff changeset
38 #include <Fonts.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
39
2277
df7e26b5c918 Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents: 2226
diff changeset
40 #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
41 #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
42 #define USE_SIOUX
2277
df7e26b5c918 Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents: 2226
diff changeset
43 #endif
df7e26b5c918 Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents: 2226
diff changeset
44
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
45 #ifdef THINK_C
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
46 #include <console.h>
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
47 #endif
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
48
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
49 #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
50
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
51 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
52 extern int Py_VerboseFlag; /* For import.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
53 extern int Py_SuppressPrintingFlag; /* For ceval.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
54
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
55
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
56 /* Subroutines that live in their own file */
3750
a22438e94fe9 Old names changed to Py_GetCopyright, etc.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3477
diff changeset
57 extern char *Py_GetVersion Py_PROTO((void));
a22438e94fe9 Old names changed to Py_GetCopyright, etc.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3477
diff changeset
58 extern char *Py_GetCopyright Py_PROTO((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
59
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
60
3930
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
61 /* For Py_GetProgramName(); 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
62 static char *argv0;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
63
3930
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
64 /* 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
65 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
66 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
67
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
68 /* Flags indicating whether stdio window should stay open on termination */
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
69 static int keep_normal;
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
70 static int keep_error = 1;
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
71
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
72 /* Initialize the Mac toolbox world */
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
73
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
74 static void
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
75 init_mac_world()
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
76 {
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
77 #ifdef THINK_C
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
78 printf("\n");
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
79 #else
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
80 MaxApplZone();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
81 InitGraf(&qd.thePort);
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
82 InitFonts();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
83 InitWindows();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
84 TEInit();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
85 InitDialogs((long)0);
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
86 InitMenus();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
87 InitCursor();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
88 #endif
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
89 }
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 /* Initialization code shared by interpreter and applets */
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
92
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
93 static void
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
94 init_common()
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
95 {
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
96
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
97 /* Initialize toolboxes */
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
98 init_mac_world();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
99
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
100 #ifdef USE_MAC_SHARED_LIBRARY
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
101 /* Add the shared library to the stack of resource files */
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
102 PyMac_AddLibResources();
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 #if defined(USE_GUSI)
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
106 /* Setup GUSI */
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
107 GUSIDefaultSetup();
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
108 #endif
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
109
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
110 #ifdef USE_SIOUX
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
111 /* Set various SIOUX flags. Some are changed later based on options */
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
112 SIOUXSettings.asktosaveonclose = 0;
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
113 SIOUXSettings.showstatusline = 0;
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
114 SIOUXSettings.tabspaces = 4;
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
115 #endif
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
116
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
117 }
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
118
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
119
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
120 #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
121 /* Applet support */
2031
1739f00ffc86 Enlarged version buffer (nobody expects the spanish inquisition:-)
Jack Jansen <jack.jansen@cwi.nl>
parents: 1821
diff changeset
122
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
123 /* 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
124 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
125 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
126 {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
127 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
128 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
129 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
130 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
131
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
132 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
133 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
134 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
135 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
136 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
146 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
147 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
148 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
149 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
150 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
151 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
152 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
153 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
154 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
155
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
156 /* 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
157 void
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
158 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
159 {
1811
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
160 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
161 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
162 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
163
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
164 init_common();
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
165 argc = PyMac_GetArgv(&argv);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
166 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
167 PySys_SetArgv(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
168 err = 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
169 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
170 fflush(stdout);
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
171 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
172 /* 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
173 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
174
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
175 #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
176
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
177 /* 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
178 void
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
179 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
180 {
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
181 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
182 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
183
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
184 init_common();
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
185 argc = PyMac_GetArgv(&argv);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
186 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
187 /* 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
188 char curwd[256], *endp;
2313
ff72a5f9a4ee Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents: 2277
diff changeset
189
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
190 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
191 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
192 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
193 *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
194
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
195 chdir(curwd);
3433
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3422
diff changeset
196 #ifdef USE_GUSI
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3422
diff changeset
197 /* 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
198 PyMac_FixGUSIcd();
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3422
diff changeset
199 #endif
2313
ff72a5f9a4ee Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents: 2277
diff changeset
200 }
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
201 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
202 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
203 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
204
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
205 /*
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
206 ** PyMac_InteractiveOptions - Allow user to set options if option key is pressed
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
207 */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
208 void
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
209 PyMac_InteractiveOptions(int *inspect, int *verbose, int *suppress_print,
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
210 int *unbuffered, int *debugging, int *keep_normal,
3448
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
211 int *keep_error, int *argcp, char ***argvp)
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
212 {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
213 KeyMap rmap;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
214 unsigned char *map;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
215 short item, type;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
216 ControlHandle handle;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
217 DialogPtr dialog;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
218 Rect rect;
3448
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
219 int old_argc = *argcp;
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
220 int i;
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
221
3411
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
222 /* Default-defaults: */
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
223 *keep_error = 1;
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
224 /* Get default settings from our preference file */
3422
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
225 PyMac_PreferenceOptions(inspect, verbose, suppress_print,
67f5d29d405b - Reorganized init code
Jack Jansen <jack.jansen@cwi.nl>
parents: 3411
diff changeset
226 unbuffered, debugging, keep_normal, keep_error);
3411
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
227 /* If option is pressed override these */
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
228 GetKeys(rmap);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
229 map = (unsigned char *)rmap;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
230 if ( ( map[0x3a>>3] & (1<<(0x3a&7)) ) == 0 ) /* option key is 3a */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
231 return;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
232
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
233 dialog = GetNewDialog(OPT_DIALOG, NULL, (WindowPtr)-1);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
234 if ( dialog == NULL ) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
235 printf("Option dialog not found - cannot set options\n");
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
236 return;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
237 }
3448
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
238 SetDialogDefaultItem(dialog, OPT_OK);
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
239 SetDialogCancelItem(dialog, OPT_CANCEL);
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
240
3411
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
241 /* Set default values */
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
242 #define SET_OPT_ITEM(num, var) \
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
243 GetDialogItem(dialog, (num), &type, (Handle *)&handle, &rect); \
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
244 SetCtlValue(handle, (short)*(var));
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
245
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
246 SET_OPT_ITEM(OPT_INSPECT, inspect);
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
247 SET_OPT_ITEM(OPT_VERBOSE, verbose);
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
248 SET_OPT_ITEM(OPT_SUPPRESS, suppress_print);
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
249 SET_OPT_ITEM(OPT_UNBUFFERED, unbuffered);
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
250 SET_OPT_ITEM(OPT_DEBUGGING, debugging);
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
251 SET_OPT_ITEM(OPT_KEEPNORMAL, keep_normal);
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
252 SET_OPT_ITEM(OPT_KEEPERROR, keep_error);
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
253
14991c4331df Store default startup options in preference file or
Jack Jansen <jack.jansen@cwi.nl>
parents: 3247
diff changeset
254 #undef SET_OPT_ITEM
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
255
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
256 while (1) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
257 handle = NULL;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
258 ModalDialog(NULL, &item);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
259 if ( item == OPT_OK )
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
260 break;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
261 if ( item == OPT_CANCEL ) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
262 DisposDialog(dialog);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
263 exit(0);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
264 }
3448
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
265 if ( item == OPT_CMDLINE ) {
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
266 int new_argc, newer_argc;
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
267 char **new_argv, **newer_argv;
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
268
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
269 new_argc = ccommand(&new_argv);
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
270 newer_argc = (new_argc-1) + old_argc;
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
271 newer_argv = malloc((newer_argc+1)*sizeof(char *));
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
272 if( !newer_argv )
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
273 Py_FatalError("Cannot malloc argv\n");
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
274 for(i=0; i<old_argc; i++)
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
275 newer_argv[i] = (*argvp)[i];
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
276 for(i=old_argc; i<=newer_argc; i++) /* Copy the NULL too */
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
277 newer_argv[i] = new_argv[i-old_argc+1];
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
278 *argvp = newer_argv;
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
279 *argcp = newer_argc;
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
280
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
281 /* XXXX Is it not safe to use free() here, apparently */
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
282 }
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
283 #define OPT_ITEM(num, var) \
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
284 if ( item == (num) ) { \
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
285 *(var) = !*(var); \
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
286 GetDialogItem(dialog, (num), &type, (Handle *)&handle, &rect); \
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
287 SetCtlValue(handle, (short)*(var)); \
2313
ff72a5f9a4ee Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents: 2277
diff changeset
288 }
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
289
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
290 OPT_ITEM(OPT_INSPECT, inspect);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
291 OPT_ITEM(OPT_VERBOSE, verbose);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
292 OPT_ITEM(OPT_SUPPRESS, suppress_print);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
293 OPT_ITEM(OPT_UNBUFFERED, unbuffered);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
294 OPT_ITEM(OPT_DEBUGGING, debugging);
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
295 OPT_ITEM(OPT_KEEPNORMAL, keep_normal);
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
296 OPT_ITEM(OPT_KEEPERROR, keep_error);
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
297
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
298 #undef OPT_ITEM
2313
ff72a5f9a4ee Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents: 2277
diff changeset
299 }
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
300 DisposDialog(dialog);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
301 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
302 /* 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
303
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
304 int
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
305 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
306 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
307 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
308 {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
309 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
310 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
311 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
312 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
313 int inspect = 0;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
314 int unbuffered = 0;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
315
3448
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
316 PyMac_InteractiveOptions(&inspect, &Py_VerboseFlag, &Py_SuppressPrintingFlag,
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
317 &unbuffered, &Py_DebugFlag, &keep_normal, &keep_error, &argc, &argv);
f91f6198b276 - Allow setting of argc/argv in <option>-start dialog
Jack Jansen <jack.jansen@cwi.nl>
parents: 3442
diff changeset
318
3930
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
319 orig_argc = argc; /* For Py_GetArgcArgv() */
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
320 orig_argv = argv;
3930
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
321 argv0 = argv[0]; /* For Py_GetProgramName() */
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
322
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
323 if (unbuffered) {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
324 #ifndef MPW
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
325 setbuf(stdout, (char *)NULL);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
326 setbuf(stderr, (char *)NULL);
2313
ff72a5f9a4ee Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents: 2277
diff changeset
327 #else
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
328 /* On MPW (3.2) unbuffered seems to hang */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
329 setvbuf(stdout, (char *)NULL, _IOLBF, BUFSIZ);
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
330 setvbuf(stderr, (char *)NULL, _IOLBF, BUFSIZ);
2313
ff72a5f9a4ee Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents: 2277
diff changeset
331 #endif
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
332 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
333
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
334 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
335
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
336 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
337 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
338 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
339 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
340
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
341 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
342 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
343 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
344 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
345 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
346 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
347 }
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 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
350
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
351 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
352
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
353 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
354 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
355 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
356 (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
357 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
358 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
359 }
1811
ea5b13d11a13 Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff changeset
360 }
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
361 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
362 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
363 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
364 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
365
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
366 if (inspect && isatty((int)fileno(stdin)) &&
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
367 (filename != NULL || 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
368 sts = PyRun_AnyFile(stdin, "<stdin>") != 0;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
369
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
370 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
371 /*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
372 }
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
373
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
374 /*
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
375 ** Terminate application
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
376 */
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
377 PyMac_Exit(status)
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
378 int status;
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
379 {
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
380 int keep;
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
381
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
382 if ( status )
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
383 keep = keep_error;
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
384 else
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
385 keep = keep_normal;
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
386
3247
20d74fa3b50b For MW Python, update titlebar of window when python exits.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3236
diff changeset
387 #ifdef USE_SIOUX
20d74fa3b50b For MW Python, update titlebar of window when python exits.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3236
diff changeset
388 if (keep) {
20d74fa3b50b For MW Python, update titlebar of window when python exits.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3236
diff changeset
389 SIOUXSettings.standalone = 1;
20d74fa3b50b For MW Python, update titlebar of window when python exits.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3236
diff changeset
390 SIOUXSettings.autocloseonquit = 0;
3477
a4f01d43dad6 Replaced non-ascii chars by backslash escapes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3465
diff changeset
391 SIOUXSetTitle("\p\307terminated\310");
3247
20d74fa3b50b For MW Python, update titlebar of window when python exits.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3236
diff changeset
392 }
3236
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
393 else
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
394 SIOUXSettings.autocloseonquit = 1;
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
395 #endif
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
396 #ifdef THINK_C
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
397 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
398 #endif
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
399
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
400 exit(status);
463b26fa4d7b Added options for keeping window open on normal/error termination
Jack Jansen <jack.jansen@cwi.nl>
parents: 3228
diff changeset
401 }
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
402
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
403 /* Return the program name -- some code out there needs this. */
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
404
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
405 char *
3930
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
406 Py_GetProgramName()
2985
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
407 {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
408 return argv0;
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
409 }
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
410
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
411
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
412 /* 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
413 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
414
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
415 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
416 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
417 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
418 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
419 {
0d7100ffb61a This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents: 2313
diff changeset
420 *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
421 *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
422 }
3930
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
423
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
424 /* 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
425
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
426 char *
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
427 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
428 {
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
429 return "";
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
430 }
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
431
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
432 char *
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
433 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
434 {
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
435 return "";
52c19ee83a6b Guido's 1.4b2 fixes: Py_GetProgramName, Py_GetPrefix and Py_GetExecPrefix.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3750
diff changeset
436 }