Guido van Rossum | b0f3c82 | 1994-08-23 13:34:25 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | 9954699 | 1995-01-08 14:33:34 +0000 | [diff] [blame] | 2 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 3 | The Netherlands. |
Guido van Rossum | b0f3c82 | 1994-08-23 13:34:25 +0000 | [diff] [blame] | 4 | |
| 5 | All Rights Reserved |
| 6 | |
| 7 | Permission to use, copy, modify, and distribute this software and its |
| 8 | documentation for any purpose and without fee is hereby granted, |
| 9 | provided that the above copyright notice appear in all copies and that |
| 10 | both that copyright notice and this permission notice appear in |
| 11 | supporting documentation, and that the names of Stichting Mathematisch |
| 12 | Centrum or CWI not be used in advertising or publicity pertaining to |
| 13 | distribution of the software without specific, written prior permission. |
| 14 | |
| 15 | STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
| 16 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 17 | FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
| 18 | FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 20 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 21 | OF 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 Rossum | 5c83252 | 1995-01-17 15:57:48 +0000 | [diff] [blame] | 31 | #include "rename2.h" |
Jack Jansen | f950f8d | 1995-02-13 11:35:34 +0000 | [diff] [blame] | 32 | #include "mymalloc.h" |
Guido van Rossum | 5c83252 | 1995-01-17 15:57:48 +0000 | [diff] [blame] | 33 | |
Guido van Rossum | b0f3c82 | 1994-08-23 13:34:25 +0000 | [diff] [blame] | 34 | #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 Jansen | c76fd39 | 1995-02-02 14:27:31 +0000 | [diff] [blame] | 45 | #ifdef __MWERKS__ |
| 46 | #include <SIOUX.h> |
| 47 | #endif |
| 48 | |
Jack Jansen | f950f8d | 1995-02-13 11:35:34 +0000 | [diff] [blame] | 49 | extern char *fileargument; |
Jack Jansen | bac428d | 1994-12-14 13:47:30 +0000 | [diff] [blame] | 50 | |
Guido van Rossum | b0f3c82 | 1994-08-23 13:34:25 +0000 | [diff] [blame] | 51 | main(argc, argv) |
| 52 | int argc; |
| 53 | char **argv; |
| 54 | { |
Jack Jansen | f950f8d | 1995-02-13 11:35:34 +0000 | [diff] [blame] | 55 | #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 Rossum | b0f3c82 | 1994-08-23 13:34:25 +0000 | [diff] [blame] | 63 | #ifdef USE_STDWIN |
Guido van Rossum | c02311b | 1995-01-22 18:38:12 +0000 | [diff] [blame] | 64 | #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 Jansen | f950f8d | 1995-02-13 11:35:34 +0000 | [diff] [blame] | 78 | printf("\n"); |
Guido van Rossum | c02311b | 1995-01-22 18:38:12 +0000 | [diff] [blame] | 79 | #endif |
Jack Jansen | f950f8d | 1995-02-13 11:35:34 +0000 | [diff] [blame] | 80 | #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 Rossum | b0f3c82 | 1994-08-23 13:34:25 +0000 | [diff] [blame] | 107 | /* Use STDWIN's wargs() to set argc/argv to list of files to open */ |
| 108 | wargs(&argc, &argv); |
Jack Jansen | f950f8d | 1995-02-13 11:35:34 +0000 | [diff] [blame] | 109 | #endif |
Guido van Rossum | b0f3c82 | 1994-08-23 13:34:25 +0000 | [diff] [blame] | 110 | /* Put About Python... in Apple menu */ |
| 111 | { |
| 112 | extern char *about_message; |
| 113 | extern char *about_item; |
| 114 | extern char *getversion(), *getcopyright(); |
Jack Jansen | bac428d | 1994-12-14 13:47:30 +0000 | [diff] [blame] | 115 | static char buf[1024]; |
Guido van Rossum | b0f3c82 | 1994-08-23 13:34:25 +0000 | [diff] [blame] | 116 | sprintf(buf, "Python %s\r\ |
| 117 | \r\ |
| 118 | %s\r\ |
| 119 | \r\ |
| 120 | Author: Guido van Rossum <guido@cwi.nl>\r\ |
| 121 | FTP: host ftp.cwi.nl, directory pub/python\r\ |
| 122 | Newsgroup: comp.lang.python\r\ |
| 123 | \r\ |
| 124 | Motto: \"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 Jansen | bac428d | 1994-12-14 13:47:30 +0000 | [diff] [blame] | 140 | if ( argc > 1 ) |
| 141 | fileargument = argv[1]; /* Mod by Jack to do chdir */ |
Guido van Rossum | b0f3c82 | 1994-08-23 13:34:25 +0000 | [diff] [blame] | 142 | realmain(argc, argv); |
| 143 | } |