blob: 2aee24941c30048d08df62876c4da8b3473ec410 [file] [log] [blame]
Guido van Rossumf56e3db1993-04-01 20:59:32 +00001/***********************************************************
2Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
3Amsterdam, The Netherlands.
4
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/* Python interpreter main program for frozen scripts */
26
27#include "allobjects.h"
28
29extern char *getenv();
30
31extern int debugging;
32extern int verbose;
Guido van Rossum9e90a671993-06-24 11:10:19 +000033extern int killprint;
Guido van Rossumf56e3db1993-04-01 20:59:32 +000034
35main(argc, argv)
36 int argc;
37 char **argv;
38{
39 char *p;
Guido van Rossum9e90a671993-06-24 11:10:19 +000040 int n, inspect, sts;
Guido van Rossum9e90a671993-06-24 11:10:19 +000041
Guido van Rossumf56e3db1993-04-01 20:59:32 +000042 if ((p = getenv("PYTHONDEBUG")) && *p != '\0')
43 debugging = 1;
44 if ((p = getenv("PYTHONVERBOSE")) && *p != '\0')
45 verbose = 1;
Guido van Rossum9e90a671993-06-24 11:10:19 +000046 if ((p = getenv("PYTHONINSPECT")) && *p != '\0')
47 inspect = 1;
48 if ((p = getenv("PYTHONKILLPRINT")) && *p != '\0')
49 killprint = 1;
50
51 initargs(&argc, &argv);
Guido van Rossumf56e3db1993-04-01 20:59:32 +000052 initall();
53 setpythonargv(argc, argv);
Guido van Rossum9e90a671993-06-24 11:10:19 +000054
Guido van Rossumf56e3db1993-04-01 20:59:32 +000055 n = init_frozen("__main__");
56 if (n == 0)
57 fatal("__main__ not frozen");
58 if (n < 0) {
59 print_error();
Guido van Rossum9e90a671993-06-24 11:10:19 +000060 sts = 1;
Guido van Rossumf56e3db1993-04-01 20:59:32 +000061 }
62 else
Guido van Rossum9e90a671993-06-24 11:10:19 +000063 sts = 0;
64
Guido van Rossumf1dc5661993-07-05 10:31:29 +000065 if (inspect && isatty((int)fileno(stdin)))
Guido van Rossum9e90a671993-06-24 11:10:19 +000066 sts = run(stdin, "<stdin>") != 0;
67
68 goaway(sts);
Guido van Rossumf56e3db1993-04-01 20:59:32 +000069 /*NOTREACHED*/
70}