blob: 8f35ea5b92bc550efe641a15d226ee49b0fdc9cf [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 Rossum094885b1993-11-05 10:16:09 +000040 int n, sts;
41 int inspect = 0;
Guido van Rossum9e90a671993-06-24 11:10:19 +000042
Guido van Rossumf56e3db1993-04-01 20:59:32 +000043 if ((p = getenv("PYTHONDEBUG")) && *p != '\0')
44 debugging = 1;
45 if ((p = getenv("PYTHONVERBOSE")) && *p != '\0')
46 verbose = 1;
Guido van Rossum9e90a671993-06-24 11:10:19 +000047 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 Rossumf56e3db1993-04-01 20:59:32 +000053 initall();
54 setpythonargv(argc, argv);
Guido van Rossum9e90a671993-06-24 11:10:19 +000055
Guido van Rossumf56e3db1993-04-01 20:59:32 +000056 n = init_frozen("__main__");
57 if (n == 0)
58 fatal("__main__ not frozen");
59 if (n < 0) {
60 print_error();
Guido van Rossum9e90a671993-06-24 11:10:19 +000061 sts = 1;
Guido van Rossumf56e3db1993-04-01 20:59:32 +000062 }
63 else
Guido van Rossum9e90a671993-06-24 11:10:19 +000064 sts = 0;
65
Guido van Rossumf1dc5661993-07-05 10:31:29 +000066 if (inspect && isatty((int)fileno(stdin)))
Guido van Rossum9e90a671993-06-24 11:10:19 +000067 sts = run(stdin, "<stdin>") != 0;
68
69 goaway(sts);
Guido van Rossumf56e3db1993-04-01 20:59:32 +000070 /*NOTREACHED*/
71}