Mercurial > cpython-lru_cache-weakref
annotate Mac/Python/macmain.c @ 2985:0d7100ffb61a legacy-trunk
This is completely different from the old mainmain (which wasn't used
anymore) and is the new main program for MacPython. Built from bits
and pieces of config.c, macglue.c and pythonmain.c.
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Mon, 14 Aug 1995 12:33:20 +0000 |
| parents | ff72a5f9a4ee |
| children | a946e4cc6d5b |
| 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 | 2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 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> |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 |
|
2277
df7e26b5c918
Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents:
2226
diff
changeset
|
39 #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
|
40 #include <SIOUX.h> |
|
df7e26b5c918
Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents:
2226
diff
changeset
|
41 #endif |
|
df7e26b5c918
Added stuff so CodeWarrior isn't so verbose about its stdio windows
Jack Jansen <jack.jansen@cwi.nl>
parents:
2226
diff
changeset
|
42 |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
43 #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
|
44 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
45 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
|
46 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
|
47 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
|
48 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
49 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
50 /* Subroutines that live in their own file */ |
|
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 char *getversion(); |
|
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 char *getcopyright(); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
53 |
|
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 /* For getprogramname(); set by main() */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
56 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
|
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 /* For getargcargv(); set by main() */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
59 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
|
60 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
|
61 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
62 #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
|
63 /* Applet support */ |
|
2031
1739f00ffc86
Enlarged version buffer (nobody expects the spanish inquisition:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
1821
diff
changeset
|
64 |
|
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 /* 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
|
66 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
|
67 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
|
68 { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
69 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
|
70 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
|
71 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
|
72 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
|
73 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
74 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
|
75 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
|
76 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
|
77 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
|
78 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
94 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
|
95 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
|
96 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
97 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
98 /* 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
|
99 void |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
100 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
|
101 { |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
106 #ifdef USE_MAC_SHARED_LIBRARY |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
107 PyMac_AddLibResources(); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
108 #endif |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
109 #ifdef __MWERKS__ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
110 SIOUXSettings.asktosaveonclose = 0; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
111 SIOUXSettings.showstatusline = 0; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
112 SIOUXSettings.tabspaces = 4; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
113 #endif |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 fflush(stdout); |
|
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 __MWERKS__ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
121 if (!err) |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
122 SIOUXSettings.autocloseonquit = 1; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
123 else |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
124 printf("\n[Terminated]\n"); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
125 #endif |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
126 /* 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
|
127 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
128 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
129 #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
|
130 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
131 /* 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
|
132 void |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
133 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
|
134 { |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
135 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
|
136 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
|
137 |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
138 #ifdef USE_MAC_SHARED_LIBRARY |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
139 PyMac_AddLibResources(); |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
140 #endif |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
141 #ifdef __MWERKS__ |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
142 SIOUXSettings.asktosaveonclose = 0; |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
143 SIOUXSettings.showstatusline = 0; |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
144 SIOUXSettings.tabspaces = 4; |
|
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
145 #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
|
146 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
|
147 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
|
148 /* 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
|
149 char curwd[256], *endp; |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
150 |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
151 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
|
152 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
|
153 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
|
154 *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
|
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 chdir(curwd); |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
157 } |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
158 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
159 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
|
160 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
161 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
162 /* |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
163 ** 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
|
164 */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
165 void |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
166 PyMac_InteractiveOptions(int *inspect, int *verbose, int *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
|
167 int *unbuffered, int *debugging) |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
168 { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
169 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
|
170 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
|
171 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
|
172 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
|
173 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
|
174 Rect rect; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
175 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
176 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
|
177 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
|
178 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
|
179 return; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
180 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
181 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
|
182 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
|
183 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
|
184 return; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
185 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
186 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
|
187 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
|
188 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
|
189 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
|
190 break; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
191 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
|
192 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
|
193 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
|
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 #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
|
196 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
|
197 *(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
|
198 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
|
199 SetCtlValue(handle, (short)*(var)); \ |
|
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 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
|
203 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
|
204 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
|
205 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
|
206 OPT_ITEM(OPT_DEBUGGING, debugging); |
|
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 #undef OPT_ITEM |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
209 } |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
210 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
|
211 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
212 /* 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
|
213 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
214 int |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
215 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
|
216 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
|
217 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
|
218 { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
219 int c; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
220 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
|
221 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
|
222 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
|
223 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
|
224 char *p; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
225 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
|
226 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
|
227 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
228 orig_argc = argc; /* For getargcargv() */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
229 orig_argv = argv; |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
230 argv0 = argv[0]; /* For getprogramname() */ |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
231 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
232 PyMac_InteractiveOptions(&inspect, &Py_VerboseFlag, &Py_SuppressPrintingFlag, |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
233 &unbuffered, &Py_DebugFlag); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
234 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
235 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
236 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
|
237 #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
|
238 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
|
239 setbuf(stderr, (char *)NULL); |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
240 #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
|
241 /* 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
|
242 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
|
243 setvbuf(stderr, (char *)NULL, _IOLBF, BUFSIZ); |
|
2313
ff72a5f9a4ee
Various changes wrt shared-library python:
Jack Jansen <jack.jansen@cwi.nl>
parents:
2277
diff
changeset
|
244 #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
|
245 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
246 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
247 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
|
248 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
249 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
|
250 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
|
251 fprintf(stderr, "Python %s\n%s\n", |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
252 getversion(), 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
|
253 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
254 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
|
255 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
|
256 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
|
257 argv[0], filename); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
258 exit(2); |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
259 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
260 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
261 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
262 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
|
263 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
264 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
|
265 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
266 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
|
267 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
|
268 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
|
269 (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
|
270 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
|
271 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
|
272 } |
|
1811
ea5b13d11a13
Added macmain.c (separate Mac specific main prog); bump version to 1.1
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
273 } |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
274 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
|
275 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
|
276 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
|
277 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
|
278 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
279 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
|
280 (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
|
281 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
|
282 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
283 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
|
284 /*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
|
285 } |
|
2985
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
286 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
287 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
288 /* 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
|
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 char * |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
291 getprogramname() |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
292 { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
293 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
|
294 } |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
295 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
296 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
297 /* 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
|
298 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
|
299 |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
300 void |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
301 getargcargv(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
|
302 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
|
303 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
|
304 { |
|
0d7100ffb61a
This is completely different from the old mainmain (which wasn't used
Jack Jansen <jack.jansen@cwi.nl>
parents:
2313
diff
changeset
|
305 *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
|
306 *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
|
307 } |
