blob: c32365e1c19f88c17726d1ebdee5e8b41cef9aa4 [file] [log] [blame]
Guido van Rossumb0f3c821994-08-23 13:34:25 +00001/***********************************************************
Guido van Rossum99546991995-01-08 14:33:34 +00002Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3The Netherlands.
Guido van Rossumb0f3c821994-08-23 13:34:25 +00004
5 All Rights Reserved
6
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting documentation, and that the names of Stichting Mathematisch
12Centrum or CWI not be used in advertising or publicity pertaining to
13distribution of the software without specific, written prior permission.
14
15STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23******************************************************************/
24
25/* Macintosh Python main program */
26
27#ifdef HAVE_CONFIG_H
28#include "config.h"
29#endif
30
Guido van Rossum5c832521995-01-17 15:57:48 +000031#include "rename2.h"
Jack Jansenf950f8d1995-02-13 11:35:34 +000032#include "mymalloc.h"
Guido van Rossum5c832521995-01-17 15:57:48 +000033
Guido van Rossumb0f3c821994-08-23 13:34:25 +000034#ifdef THINK_C
35#define CONSOLE_IO
36#endif
37
38#include <stdio.h>
39#include <string.h>
40
41#ifdef CONSOLE_IO
42#include <console.h>
43#endif
44
Jack Jansenc76fd391995-02-02 14:27:31 +000045#ifdef __MWERKS__
46#include <SIOUX.h>
47#endif
48
Jack Jansenf950f8d1995-02-13 11:35:34 +000049extern char *fileargument;
Jack Jansenbac428d1994-12-14 13:47:30 +000050
Guido van Rossumb0f3c821994-08-23 13:34:25 +000051main(argc, argv)
52 int argc;
53 char **argv;
54{
Jack Jansenf950f8d1995-02-13 11:35:34 +000055#ifdef USE_MAC_SHARED_LIBRARY
56 PyMac_AddLibResources();
57#endif
58#ifdef __MWERKS__
59 SIOUXSettings.asktosaveonclose = 0;
60 SIOUXSettings.showstatusline = 0;
61 SIOUXSettings.tabspaces = 4;
62#endif
Guido van Rossumb0f3c821994-08-23 13:34:25 +000063#ifdef USE_STDWIN
Guido van Rossumc02311b1995-01-22 18:38:12 +000064#ifdef THINK_C
65 /* This is done to initialize the Think console I/O library before stdwin.
66 If we don't do this, the console I/O library will only be usable for
67 output, and the interactive version of the interpreter will quit
68 immediately because it sees an EOF from stdin.
69 The disadvantage is that when using STDWIN, your stdwin menus will
70 appear next to the console I/O's File and Edit menus, and you will have
71 an empty console window in your application (though it can be removed
72 by clever use of console library I believe).
73 Remove this line if you want to be able to double-click Python scripts
74 that use STDWIN and never use stdin for input.
75 (A more dynamic solution may be possible e.g. based on bits in the
76 SIZE resource or whatever... Have fun, and let me know if you find
77 a better way!) */
Jack Jansenf950f8d1995-02-13 11:35:34 +000078 printf("\n");
Guido van Rossumc02311b1995-01-22 18:38:12 +000079#endif
Jack Jansenf950f8d1995-02-13 11:35:34 +000080#ifdef BUILD_APPLET_TEMPLATE
81 /* Make argv[0] and [1] be application name. The "argument" will later
82 ** be recognized as APPL type and interpreted as being a .pyc file.
83 ** XXXX Should be changed. Argv[0] should be the shared lib location or
84 ** something, so we can find our Lib directory, etc.
85 */
86 {
87 char *progname;
88 extern char *getappname();
89
90 progname = getappname();
91 if ( (argv = (char **)malloc(3*sizeof(char *))) == NULL ) {
92 fprintf(stderr, "No memory\n");
93 exit(1);
94 }
95 argv[0] = malloc(strlen(progname)+1);
96 argv[1] = malloc(strlen(progname)+1);
97 argv[2] = NULL;
98 if ( argv[0] == NULL || argv[1] == NULL ) {
99 fprintf(stderr, "No memory\n");
100 exit(1);
101 }
102 strcpy(argv[0], progname);
103 strcpy(argv[1], progname);
104 argc = 2;
105 }
106#else
Guido van Rossumb0f3c821994-08-23 13:34:25 +0000107 /* Use STDWIN's wargs() to set argc/argv to list of files to open */
108 wargs(&argc, &argv);
Jack Jansenf950f8d1995-02-13 11:35:34 +0000109#endif
Guido van Rossumb0f3c821994-08-23 13:34:25 +0000110 /* Put About Python... in Apple menu */
111 {
112 extern char *about_message;
113 extern char *about_item;
114 extern char *getversion(), *getcopyright();
Jack Jansenbac428d1994-12-14 13:47:30 +0000115 static char buf[1024];
Guido van Rossumb0f3c821994-08-23 13:34:25 +0000116 sprintf(buf, "Python %s\r\
117\r\
118%s\r\
119\r\
120Author: Guido van Rossum <guido@cwi.nl>\r\
121FTP: host ftp.cwi.nl, directory pub/python\r\
122Newsgroup: comp.lang.python\r\
123\r\
124Motto: \"Nobody expects the Spanish Inquisition!\"",
125 getversion(), getcopyright());
126 about_message = buf;
127 about_item = "About Python...";
128 }
129#endif /* USE_STDWIN */
130#ifdef CONSOLE_IO
131 if (argc >= 1 && argv[0][0] != '\0') {
132 static char buf[256];
133 buf[0] = strlen(argv[0]);
134 strncpy(buf+1, argv[0], buf[0]);
135 console_options.title = (unsigned char *)buf;
136 }
137 else
138 console_options.title = "\pPython";
139#endif /* CONSOLE_IO */
Jack Jansenbac428d1994-12-14 13:47:30 +0000140 if ( argc > 1 )
141 fileargument = argv[1]; /* Mod by Jack to do chdir */
Guido van Rossumb0f3c821994-08-23 13:34:25 +0000142 realmain(argc, argv);
143}