Guido van Rossum | f56e3db | 1993-04-01 20:59:32 +0000 | [diff] [blame] | 1 | /*********************************************************** |
| 2 | Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, |
| 3 | Amsterdam, The Netherlands. |
| 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 | /* Python interpreter main program for frozen scripts */ |
| 26 | |
| 27 | #include "allobjects.h" |
| 28 | |
| 29 | extern char *getenv(); |
| 30 | |
| 31 | extern int debugging; |
| 32 | extern int verbose; |
Guido van Rossum | 9e90a67 | 1993-06-24 11:10:19 +0000 | [diff] [blame] | 33 | extern int killprint; |
Guido van Rossum | f56e3db | 1993-04-01 20:59:32 +0000 | [diff] [blame] | 34 | |
| 35 | main(argc, argv) |
| 36 | int argc; |
| 37 | char **argv; |
| 38 | { |
| 39 | char *p; |
Guido van Rossum | 094885b | 1993-11-05 10:16:09 +0000 | [diff] [blame] | 40 | int n, sts; |
| 41 | int inspect = 0; |
Guido van Rossum | 9e90a67 | 1993-06-24 11:10:19 +0000 | [diff] [blame] | 42 | |
Guido van Rossum | f56e3db | 1993-04-01 20:59:32 +0000 | [diff] [blame] | 43 | if ((p = getenv("PYTHONDEBUG")) && *p != '\0') |
| 44 | debugging = 1; |
| 45 | if ((p = getenv("PYTHONVERBOSE")) && *p != '\0') |
| 46 | verbose = 1; |
Guido van Rossum | 9e90a67 | 1993-06-24 11:10:19 +0000 | [diff] [blame] | 47 | if ((p = getenv("PYTHONINSPECT")) && *p != '\0') |
| 48 | inspect = 1; |
| 49 | if ((p = getenv("PYTHONKILLPRINT")) && *p != '\0') |
| 50 | killprint = 1; |
| 51 | |
| 52 | initargs(&argc, &argv); |
Guido van Rossum | f56e3db | 1993-04-01 20:59:32 +0000 | [diff] [blame] | 53 | initall(); |
| 54 | setpythonargv(argc, argv); |
Guido van Rossum | 9e90a67 | 1993-06-24 11:10:19 +0000 | [diff] [blame] | 55 | |
Guido van Rossum | f56e3db | 1993-04-01 20:59:32 +0000 | [diff] [blame] | 56 | n = init_frozen("__main__"); |
| 57 | if (n == 0) |
| 58 | fatal("__main__ not frozen"); |
| 59 | if (n < 0) { |
| 60 | print_error(); |
Guido van Rossum | 9e90a67 | 1993-06-24 11:10:19 +0000 | [diff] [blame] | 61 | sts = 1; |
Guido van Rossum | f56e3db | 1993-04-01 20:59:32 +0000 | [diff] [blame] | 62 | } |
| 63 | else |
Guido van Rossum | 9e90a67 | 1993-06-24 11:10:19 +0000 | [diff] [blame] | 64 | sts = 0; |
| 65 | |
Guido van Rossum | f1dc566 | 1993-07-05 10:31:29 +0000 | [diff] [blame] | 66 | if (inspect && isatty((int)fileno(stdin))) |
Guido van Rossum | 9e90a67 | 1993-06-24 11:10:19 +0000 | [diff] [blame] | 67 | sts = run(stdin, "<stdin>") != 0; |
| 68 | |
| 69 | goaway(sts); |
Guido van Rossum | f56e3db | 1993-04-01 20:59:32 +0000 | [diff] [blame] | 70 | /*NOTREACHED*/ |
| 71 | } |