blob: 5f6a67f538c5ace19ee1b5874b8d5e04ba80b9dd [file] [log] [blame]
Guido van Rossumf70e43a1991-02-19 12:39:46 +00001
Guido van Rossum3f5da241990-12-20 15:06:42 +00002/* Interfaces to parse and execute pieces of python code */
3
Fred Drake3cf4d2b2000-07-09 00:55:06 +00004#ifndef Py_PYTHONRUN_H
5#define Py_PYTHONRUN_H
6#ifdef __cplusplus
7extern "C" {
8#endif
Guido van Rossum57d8e3f1997-07-19 19:50:52 +00009
Tim Peters2bbdba32002-04-12 01:20:10 +000010#define PyCF_MASK (CO_FUTURE_DIVISION)
11#define PyCF_MASK_OBSOLETE (CO_GENERATOR_ALLOWED | CO_NESTED)
Tim Peterse2c18e92001-08-17 20:47:47 +000012
Jeremy Hylton9f324e92001-03-01 22:59:14 +000013typedef struct {
Jeremy Hyltonfdd12f62001-08-10 21:38:04 +000014 int cf_flags; /* bitmask of CO_xxx flags relevant to future */
Jeremy Hylton9f324e92001-03-01 22:59:14 +000015} PyCompilerFlags;
16
Mark Hammond91a681d2002-08-12 07:21:58 +000017PyAPI_FUNC(void) Py_SetProgramName(char *);
18PyAPI_FUNC(char *) Py_GetProgramName(void);
Guido van Rossum66d4b901998-02-06 22:28:05 +000019
Mark Hammond91a681d2002-08-12 07:21:58 +000020PyAPI_FUNC(void) Py_SetPythonHome(char *);
21PyAPI_FUNC(char *) Py_GetPythonHome(void);
Guido van Rossum3f5da241990-12-20 15:06:42 +000022
Mark Hammond91a681d2002-08-12 07:21:58 +000023PyAPI_FUNC(void) Py_Initialize(void);
24PyAPI_FUNC(void) Py_Finalize(void);
25PyAPI_FUNC(int) Py_IsInitialized(void);
26PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
27PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
Guido van Rossum3f5da241990-12-20 15:06:42 +000028
Martin v. Löwis95292d62002-12-11 14:04:59 +000029PyAPI_FUNC(int) PyRun_AnyFile(FILE *, const char *);
30PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *, const char *, int);
Guido van Rossum3f5da241990-12-20 15:06:42 +000031
Martin v. Löwis95292d62002-12-11 14:04:59 +000032PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
33PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
Jeremy Hyltonbc320242001-03-22 02:47:58 +000034
Martin v. Löwis95292d62002-12-11 14:04:59 +000035PyAPI_FUNC(int) PyRun_SimpleString(const char *);
36PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
37PyAPI_FUNC(int) PyRun_SimpleFile(FILE *, const char *);
38PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *, const char *, int);
39PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
40PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *, const char *);
41PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *);
42PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *, const char *);
43PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *);
Guido van Rossum3f5da241990-12-20 15:06:42 +000044
Martin v. Löwis95292d62002-12-11 14:04:59 +000045PyAPI_FUNC(struct _node *) PyParser_SimpleParseString(const char *, int);
46PyAPI_FUNC(struct _node *) PyParser_SimpleParseFile(FILE *, const char *, int);
47PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, int);
48PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *,
49 const char *,
Thomas Heller6b17abf2002-07-09 09:23:27 +000050 int,
51 int);
Martin v. Löwis95292d62002-12-11 14:04:59 +000052PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
Tim Petersfe2127d2001-07-16 05:37:24 +000053 int, int);
Guido van Rossum3f5da241990-12-20 15:06:42 +000054
Martin v. Löwis95292d62002-12-11 14:04:59 +000055PyAPI_FUNC(PyObject *) PyRun_String(const char *, int, PyObject *, PyObject *);
56PyAPI_FUNC(PyObject *) PyRun_File(FILE *, const char *, int, PyObject *, PyObject *);
57PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *, const char *, int,
Guido van Rossum0df002c2000-08-27 19:21:52 +000058 PyObject *, PyObject *, int);
Martin v. Löwis95292d62002-12-11 14:04:59 +000059PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, PyObject *,
Jeremy Hyltonbc320242001-03-22 02:47:58 +000060 PyCompilerFlags *);
Martin v. Löwis95292d62002-12-11 14:04:59 +000061PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *, const char *, int, PyObject *,
Jeremy Hyltonbc320242001-03-22 02:47:58 +000062 PyObject *, PyCompilerFlags *);
Martin v. Löwis95292d62002-12-11 14:04:59 +000063PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int, PyObject *,
Jeremy Hyltonbc320242001-03-22 02:47:58 +000064 PyObject *, int, PyCompilerFlags *);
Guido van Rossum5b722181993-03-30 17:46:03 +000065
Martin v. Löwis95292d62002-12-11 14:04:59 +000066PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
67PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int,
Jeremy Hyltonbc320242001-03-22 02:47:58 +000068 PyCompilerFlags *);
Martin v. Löwis95292d62002-12-11 14:04:59 +000069PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int);
Guido van Rossum3f5da241990-12-20 15:06:42 +000070
Mark Hammond91a681d2002-08-12 07:21:58 +000071PyAPI_FUNC(void) PyErr_Print(void);
72PyAPI_FUNC(void) PyErr_PrintEx(int);
73PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
Guido van Rossumc6cf1dd1994-09-07 14:35:10 +000074
Mark Hammond91a681d2002-08-12 07:21:58 +000075PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
Guido van Rossuma3309961993-07-28 09:05:47 +000076
Mark Hammond91a681d2002-08-12 07:21:58 +000077PyAPI_FUNC(void) Py_Exit(int);
Fred Drake3cf4d2b2000-07-09 00:55:06 +000078
Martin v. Löwis95292d62002-12-11 14:04:59 +000079PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
Guido van Rossum5c4998b1997-02-14 19:51:34 +000080
Mark Hammondfe51c6d2002-08-02 02:27:13 +000081/* Bootstrap */
82PyAPI_FUNC(int) Py_Main(int argc, char **argv);
83
Guido van Rossum57d8e3f1997-07-19 19:50:52 +000084/* In getpath.c */
Mark Hammonda2905272002-07-29 13:42:14 +000085PyAPI_FUNC(char *) Py_GetProgramFullPath(void);
86PyAPI_FUNC(char *) Py_GetPrefix(void);
87PyAPI_FUNC(char *) Py_GetExecPrefix(void);
88PyAPI_FUNC(char *) Py_GetPath(void);
Guido van Rossum57d8e3f1997-07-19 19:50:52 +000089
90/* In their own files */
Mark Hammonda2905272002-07-29 13:42:14 +000091PyAPI_FUNC(const char *) Py_GetVersion(void);
92PyAPI_FUNC(const char *) Py_GetPlatform(void);
93PyAPI_FUNC(const char *) Py_GetCopyright(void);
94PyAPI_FUNC(const char *) Py_GetCompiler(void);
95PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
Guido van Rossum57d8e3f1997-07-19 19:50:52 +000096
Guido van Rossum29e46a91997-08-02 02:56:48 +000097/* Internal -- various one-time initializations */
Mark Hammond91a681d2002-08-12 07:21:58 +000098PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
99PyAPI_FUNC(PyObject *) _PySys_Init(void);
100PyAPI_FUNC(void) _PyImport_Init(void);
Mark Hammonda2905272002-07-29 13:42:14 +0000101PyAPI_FUNC(void) _PyExc_Init(void);
Just van Rossum52e14d62002-12-30 22:08:05 +0000102PyAPI_FUNC(void) _PyImportHooks_Init(void);
Neal Norwitzb2501f42002-12-31 03:42:13 +0000103PyAPI_FUNC(int) _PyFrame_Init(void);
Neal Norwitzdc392e32003-01-01 15:18:32 +0000104PyAPI_FUNC(int) _PyInt_Init(void);
Guido van Rossum29e46a91997-08-02 02:56:48 +0000105
Guido van Rossum8e5e4461997-08-12 14:57:21 +0000106/* Various internal finalizers */
Mark Hammonda2905272002-07-29 13:42:14 +0000107PyAPI_FUNC(void) _PyExc_Fini(void);
108PyAPI_FUNC(void) _PyImport_Fini(void);
109PyAPI_FUNC(void) PyMethod_Fini(void);
110PyAPI_FUNC(void) PyFrame_Fini(void);
111PyAPI_FUNC(void) PyCFunction_Fini(void);
112PyAPI_FUNC(void) PyTuple_Fini(void);
113PyAPI_FUNC(void) PyString_Fini(void);
114PyAPI_FUNC(void) PyInt_Fini(void);
115PyAPI_FUNC(void) PyFloat_Fini(void);
116PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
Guido van Rossum8e5e4461997-08-12 14:57:21 +0000117
Guido van Rossum3fb1aea1997-08-12 15:14:22 +0000118/* Stuff with no proper home (yet) */
Martin v. Löwis566f6af2002-10-26 14:39:10 +0000119PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
Mark Hammond5d546672002-08-12 13:06:35 +0000120PyAPI_DATA(int) (*PyOS_InputHook)(void);
Martin v. Löwis566f6af2002-10-26 14:39:10 +0000121PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
Fredrik Lundh2f15b252000-08-27 19:15:31 +0000122
123/* Stack size, in "pointers" (so we get extra safety margins
124 on 64-bit platforms). On a 32-bit platform, this translates
125 to a 8k margin. */
126#define PYOS_STACK_MARGIN 2048
127
Trent Mick0a7af402000-10-11 17:18:11 +0000128#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER)
Fredrik Lundh2f15b252000-08-27 19:15:31 +0000129/* Enable stack checking under Microsoft C */
130#define USE_STACKCHECK
131#endif
132
Jack Jansen275abb32000-08-07 21:00:42 +0000133#ifdef USE_STACKCHECK
Fredrik Lundh2f15b252000-08-27 19:15:31 +0000134/* Check that we aren't overflowing our stack */
Mark Hammond91a681d2002-08-12 07:21:58 +0000135PyAPI_FUNC(int) PyOS_CheckStack(void);
Jack Jansen275abb32000-08-07 21:00:42 +0000136#endif
Guido van Rossum3fb1aea1997-08-12 15:14:22 +0000137
Guido van Rossumc7247ce2000-09-16 16:31:31 +0000138/* Signals */
139typedef void (*PyOS_sighandler_t)(int);
Mark Hammond91a681d2002-08-12 07:21:58 +0000140PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
141PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
Guido van Rossumc7247ce2000-09-16 16:31:31 +0000142
143
Guido van Rossuma3309961993-07-28 09:05:47 +0000144#ifdef __cplusplus
145}
146#endif
147#endif /* !Py_PYTHONRUN_H */