blob: 746ba7ed93cc98e86064535d7cd1d319d7421e08 [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)
Just van Rossum3aaf42c2003-02-10 08:21:10 +000012#define PyCF_SOURCE_IS_UTF8 0x0100
Guido van Rossum4b499dd32003-02-13 22:07:59 +000013#define PyCF_DONT_IMPLY_DEDENT 0x0200
Tim Peterse2c18e92001-08-17 20:47:47 +000014
Jeremy Hylton9f324e92001-03-01 22:59:14 +000015typedef struct {
Jeremy Hyltonfdd12f62001-08-10 21:38:04 +000016 int cf_flags; /* bitmask of CO_xxx flags relevant to future */
Jeremy Hylton9f324e92001-03-01 22:59:14 +000017} PyCompilerFlags;
18
Mark Hammond91a681d2002-08-12 07:21:58 +000019PyAPI_FUNC(void) Py_SetProgramName(char *);
20PyAPI_FUNC(char *) Py_GetProgramName(void);
Guido van Rossum66d4b901998-02-06 22:28:05 +000021
Mark Hammond91a681d2002-08-12 07:21:58 +000022PyAPI_FUNC(void) Py_SetPythonHome(char *);
23PyAPI_FUNC(char *) Py_GetPythonHome(void);
Guido van Rossum3f5da241990-12-20 15:06:42 +000024
Mark Hammond91a681d2002-08-12 07:21:58 +000025PyAPI_FUNC(void) Py_Initialize(void);
26PyAPI_FUNC(void) Py_Finalize(void);
27PyAPI_FUNC(int) Py_IsInitialized(void);
28PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
29PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
Guido van Rossum3f5da241990-12-20 15:06:42 +000030
Martin v. Löwis95292d62002-12-11 14:04:59 +000031PyAPI_FUNC(int) PyRun_AnyFile(FILE *, const char *);
32PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *, const char *, int);
Guido van Rossum3f5da241990-12-20 15:06:42 +000033
Martin v. Löwis95292d62002-12-11 14:04:59 +000034PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
35PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
Jeremy Hyltonbc320242001-03-22 02:47:58 +000036
Martin v. Löwis95292d62002-12-11 14:04:59 +000037PyAPI_FUNC(int) PyRun_SimpleString(const char *);
38PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
39PyAPI_FUNC(int) PyRun_SimpleFile(FILE *, const char *);
40PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *, const char *, int);
41PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
42PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *, const char *);
43PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *);
44PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *, const char *);
45PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *);
Guido van Rossum3f5da241990-12-20 15:06:42 +000046
Martin v. Löwis95292d62002-12-11 14:04:59 +000047PyAPI_FUNC(struct _node *) PyParser_SimpleParseString(const char *, int);
48PyAPI_FUNC(struct _node *) PyParser_SimpleParseFile(FILE *, const char *, int);
49PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, int);
50PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *,
51 const char *,
Thomas Heller6b17abf2002-07-09 09:23:27 +000052 int,
53 int);
Martin v. Löwis95292d62002-12-11 14:04:59 +000054PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
Tim Petersfe2127d2001-07-16 05:37:24 +000055 int, int);
Guido van Rossum3f5da241990-12-20 15:06:42 +000056
Martin v. Löwis95292d62002-12-11 14:04:59 +000057PyAPI_FUNC(PyObject *) PyRun_String(const char *, int, PyObject *, PyObject *);
58PyAPI_FUNC(PyObject *) PyRun_File(FILE *, const char *, int, PyObject *, PyObject *);
59PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *, const char *, int,
Guido van Rossum0df002c2000-08-27 19:21:52 +000060 PyObject *, PyObject *, int);
Martin v. Löwis95292d62002-12-11 14:04:59 +000061PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, PyObject *,
Jeremy Hyltonbc320242001-03-22 02:47:58 +000062 PyCompilerFlags *);
Martin v. Löwis95292d62002-12-11 14:04:59 +000063PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *, const char *, int, PyObject *,
Jeremy Hyltonbc320242001-03-22 02:47:58 +000064 PyObject *, PyCompilerFlags *);
Martin v. Löwis95292d62002-12-11 14:04:59 +000065PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int, PyObject *,
Jeremy Hyltonbc320242001-03-22 02:47:58 +000066 PyObject *, int, PyCompilerFlags *);
Guido van Rossum5b722181993-03-30 17:46:03 +000067
Martin v. Löwis95292d62002-12-11 14:04:59 +000068PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
69PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int,
Jeremy Hyltonbc320242001-03-22 02:47:58 +000070 PyCompilerFlags *);
Martin v. Löwis95292d62002-12-11 14:04:59 +000071PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int);
Guido van Rossum3f5da241990-12-20 15:06:42 +000072
Mark Hammond91a681d2002-08-12 07:21:58 +000073PyAPI_FUNC(void) PyErr_Print(void);
74PyAPI_FUNC(void) PyErr_PrintEx(int);
75PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
Guido van Rossumc6cf1dd1994-09-07 14:35:10 +000076
Mark Hammond91a681d2002-08-12 07:21:58 +000077PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
Guido van Rossuma3309961993-07-28 09:05:47 +000078
Mark Hammond91a681d2002-08-12 07:21:58 +000079PyAPI_FUNC(void) Py_Exit(int);
Fred Drake3cf4d2b2000-07-09 00:55:06 +000080
Martin v. Löwis95292d62002-12-11 14:04:59 +000081PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
Guido van Rossum5c4998b1997-02-14 19:51:34 +000082
Mark Hammondfe51c6d2002-08-02 02:27:13 +000083/* Bootstrap */
84PyAPI_FUNC(int) Py_Main(int argc, char **argv);
85
Guido van Rossum57d8e3f1997-07-19 19:50:52 +000086/* In getpath.c */
Mark Hammonda2905272002-07-29 13:42:14 +000087PyAPI_FUNC(char *) Py_GetProgramFullPath(void);
88PyAPI_FUNC(char *) Py_GetPrefix(void);
89PyAPI_FUNC(char *) Py_GetExecPrefix(void);
90PyAPI_FUNC(char *) Py_GetPath(void);
Guido van Rossum57d8e3f1997-07-19 19:50:52 +000091
92/* In their own files */
Mark Hammonda2905272002-07-29 13:42:14 +000093PyAPI_FUNC(const char *) Py_GetVersion(void);
94PyAPI_FUNC(const char *) Py_GetPlatform(void);
95PyAPI_FUNC(const char *) Py_GetCopyright(void);
96PyAPI_FUNC(const char *) Py_GetCompiler(void);
97PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
Guido van Rossum57d8e3f1997-07-19 19:50:52 +000098
Guido van Rossum29e46a91997-08-02 02:56:48 +000099/* Internal -- various one-time initializations */
Mark Hammond91a681d2002-08-12 07:21:58 +0000100PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
101PyAPI_FUNC(PyObject *) _PySys_Init(void);
102PyAPI_FUNC(void) _PyImport_Init(void);
Mark Hammonda2905272002-07-29 13:42:14 +0000103PyAPI_FUNC(void) _PyExc_Init(void);
Just van Rossum52e14d62002-12-30 22:08:05 +0000104PyAPI_FUNC(void) _PyImportHooks_Init(void);
Neal Norwitzb2501f42002-12-31 03:42:13 +0000105PyAPI_FUNC(int) _PyFrame_Init(void);
Neal Norwitzdc392e32003-01-01 15:18:32 +0000106PyAPI_FUNC(int) _PyInt_Init(void);
Guido van Rossum29e46a91997-08-02 02:56:48 +0000107
Guido van Rossum8e5e4461997-08-12 14:57:21 +0000108/* Various internal finalizers */
Mark Hammonda2905272002-07-29 13:42:14 +0000109PyAPI_FUNC(void) _PyExc_Fini(void);
110PyAPI_FUNC(void) _PyImport_Fini(void);
111PyAPI_FUNC(void) PyMethod_Fini(void);
112PyAPI_FUNC(void) PyFrame_Fini(void);
113PyAPI_FUNC(void) PyCFunction_Fini(void);
114PyAPI_FUNC(void) PyTuple_Fini(void);
115PyAPI_FUNC(void) PyString_Fini(void);
116PyAPI_FUNC(void) PyInt_Fini(void);
117PyAPI_FUNC(void) PyFloat_Fini(void);
118PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
Guido van Rossum8e5e4461997-08-12 14:57:21 +0000119
Guido van Rossum3fb1aea1997-08-12 15:14:22 +0000120/* Stuff with no proper home (yet) */
Martin v. Löwis566f6af2002-10-26 14:39:10 +0000121PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
Mark Hammond5d546672002-08-12 13:06:35 +0000122PyAPI_DATA(int) (*PyOS_InputHook)(void);
Martin v. Löwis566f6af2002-10-26 14:39:10 +0000123PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
Fredrik Lundh2f15b252000-08-27 19:15:31 +0000124
125/* Stack size, in "pointers" (so we get extra safety margins
126 on 64-bit platforms). On a 32-bit platform, this translates
127 to a 8k margin. */
128#define PYOS_STACK_MARGIN 2048
129
Trent Mick0a7af402000-10-11 17:18:11 +0000130#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER)
Fredrik Lundh2f15b252000-08-27 19:15:31 +0000131/* Enable stack checking under Microsoft C */
132#define USE_STACKCHECK
133#endif
134
Jack Jansen275abb32000-08-07 21:00:42 +0000135#ifdef USE_STACKCHECK
Fredrik Lundh2f15b252000-08-27 19:15:31 +0000136/* Check that we aren't overflowing our stack */
Mark Hammond91a681d2002-08-12 07:21:58 +0000137PyAPI_FUNC(int) PyOS_CheckStack(void);
Jack Jansen275abb32000-08-07 21:00:42 +0000138#endif
Guido van Rossum3fb1aea1997-08-12 15:14:22 +0000139
Guido van Rossumc7247ce2000-09-16 16:31:31 +0000140/* Signals */
141typedef void (*PyOS_sighandler_t)(int);
Mark Hammond91a681d2002-08-12 07:21:58 +0000142PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
143PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
Guido van Rossumc7247ce2000-09-16 16:31:31 +0000144
145
Guido van Rossuma3309961993-07-28 09:05:47 +0000146#ifdef __cplusplus
147}
148#endif
149#endif /* !Py_PYTHONRUN_H */