blob: 3877a8237dde27b57ad80ee32571375ad50e1233 [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 Peters5ba58662001-07-16 02:29:45 +000010/* These flags are named after the __future__ statements that introduced
11 them. May not remain true for later additions, so fiddle this comment
12 accordingly then. */
13#define PyCF_NESTED_SCOPES (0x00000001UL)
14#define PyCF_GENERATORS (0x00000002UL)
Jeremy Hylton9f324e92001-03-01 22:59:14 +000015typedef struct {
Tim Peters5ba58662001-07-16 02:29:45 +000016 unsigned long cf_flags; /* bitmask of PyCF_xxx flags */
Jeremy Hylton9f324e92001-03-01 22:59:14 +000017} PyCompilerFlags;
18
Fred Drake3cf4d2b2000-07-09 00:55:06 +000019DL_IMPORT(void) Py_SetProgramName(char *);
20DL_IMPORT(char *) Py_GetProgramName(void);
Guido van Rossum66d4b901998-02-06 22:28:05 +000021
Fred Drake3cf4d2b2000-07-09 00:55:06 +000022DL_IMPORT(void) Py_SetPythonHome(char *);
23DL_IMPORT(char *) Py_GetPythonHome(void);
Guido van Rossum3f5da241990-12-20 15:06:42 +000024
Fred Drake3cf4d2b2000-07-09 00:55:06 +000025DL_IMPORT(void) Py_Initialize(void);
26DL_IMPORT(void) Py_Finalize(void);
27DL_IMPORT(int) Py_IsInitialized(void);
28DL_IMPORT(PyThreadState *) Py_NewInterpreter(void);
29DL_IMPORT(void) Py_EndInterpreter(PyThreadState *);
Guido van Rossum3f5da241990-12-20 15:06:42 +000030
Fred Drake3cf4d2b2000-07-09 00:55:06 +000031DL_IMPORT(int) PyRun_AnyFile(FILE *, char *);
Guido van Rossum0df002c2000-08-27 19:21:52 +000032DL_IMPORT(int) PyRun_AnyFileEx(FILE *, char *, int);
Guido van Rossum3f5da241990-12-20 15:06:42 +000033
Jeremy Hyltonbc320242001-03-22 02:47:58 +000034DL_IMPORT(int) PyRun_AnyFileFlags(FILE *, char *, PyCompilerFlags *);
35DL_IMPORT(int) PyRun_AnyFileExFlags(FILE *, char *, int, PyCompilerFlags *);
36
Fred Drake3cf4d2b2000-07-09 00:55:06 +000037DL_IMPORT(int) PyRun_SimpleString(char *);
38DL_IMPORT(int) PyRun_SimpleFile(FILE *, char *);
Guido van Rossum0df002c2000-08-27 19:21:52 +000039DL_IMPORT(int) PyRun_SimpleFileEx(FILE *, char *, int);
Jeremy Hyltonbc320242001-03-22 02:47:58 +000040DL_IMPORT(int) PyRun_SimpleFileExFlags(FILE *, char *, int, PyCompilerFlags *);
Fred Drake3cf4d2b2000-07-09 00:55:06 +000041DL_IMPORT(int) PyRun_InteractiveOne(FILE *, char *);
Jeremy Hylton9f324e92001-03-01 22:59:14 +000042DL_IMPORT(int) PyRun_InteractiveOneFlags(FILE *, char *, PyCompilerFlags *);
Fred Drake3cf4d2b2000-07-09 00:55:06 +000043DL_IMPORT(int) PyRun_InteractiveLoop(FILE *, char *);
Jeremy Hyltonbc320242001-03-22 02:47:58 +000044DL_IMPORT(int) PyRun_InteractiveLoopFlags(FILE *, char *, PyCompilerFlags *);
Guido van Rossum3f5da241990-12-20 15:06:42 +000045
Fred Drake3cf4d2b2000-07-09 00:55:06 +000046DL_IMPORT(struct _node *) PyParser_SimpleParseString(char *, int);
47DL_IMPORT(struct _node *) PyParser_SimpleParseFile(FILE *, char *, int);
Guido van Rossum3f5da241990-12-20 15:06:42 +000048
Fred Drake3cf4d2b2000-07-09 00:55:06 +000049DL_IMPORT(PyObject *) PyRun_String(char *, int, PyObject *, PyObject *);
50DL_IMPORT(PyObject *) PyRun_File(FILE *, char *, int, PyObject *, PyObject *);
Guido van Rossum0df002c2000-08-27 19:21:52 +000051DL_IMPORT(PyObject *) PyRun_FileEx(FILE *, char *, int,
52 PyObject *, PyObject *, int);
Jeremy Hyltonbc320242001-03-22 02:47:58 +000053DL_IMPORT(PyObject *) PyRun_StringFlags(char *, int, PyObject *, PyObject *,
54 PyCompilerFlags *);
55DL_IMPORT(PyObject *) PyRun_FileFlags(FILE *, char *, int, PyObject *,
56 PyObject *, PyCompilerFlags *);
57DL_IMPORT(PyObject *) PyRun_FileExFlags(FILE *, char *, int, PyObject *,
58 PyObject *, int, PyCompilerFlags *);
Guido van Rossum5b722181993-03-30 17:46:03 +000059
Fred Drake3cf4d2b2000-07-09 00:55:06 +000060DL_IMPORT(PyObject *) Py_CompileString(char *, char *, int);
Jeremy Hyltonbc320242001-03-22 02:47:58 +000061DL_IMPORT(PyObject *) Py_CompileStringFlags(char *, char *, int,
62 PyCompilerFlags *);
Jeremy Hylton4b38da62001-02-02 18:19:15 +000063DL_IMPORT(struct symtable *) Py_SymtableString(char *, char *, int);
Guido van Rossum3f5da241990-12-20 15:06:42 +000064
Fred Drake3cf4d2b2000-07-09 00:55:06 +000065DL_IMPORT(void) PyErr_Print(void);
66DL_IMPORT(void) PyErr_PrintEx(int);
Ka-Ping Yeeb5c51322001-03-23 02:46:52 +000067DL_IMPORT(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
Guido van Rossumc6cf1dd1994-09-07 14:35:10 +000068
Fred Drake3cf4d2b2000-07-09 00:55:06 +000069DL_IMPORT(int) Py_AtExit(void (*func)(void));
Guido van Rossuma3309961993-07-28 09:05:47 +000070
Fred Drake3cf4d2b2000-07-09 00:55:06 +000071DL_IMPORT(void) Py_Exit(int);
72
73DL_IMPORT(int) Py_FdIsInteractive(FILE *, char *);
Guido van Rossum5c4998b1997-02-14 19:51:34 +000074
Guido van Rossum57d8e3f1997-07-19 19:50:52 +000075/* In getpath.c */
Fred Drake3cf4d2b2000-07-09 00:55:06 +000076DL_IMPORT(char *) Py_GetProgramFullPath(void);
77DL_IMPORT(char *) Py_GetPrefix(void);
78DL_IMPORT(char *) Py_GetExecPrefix(void);
79DL_IMPORT(char *) Py_GetPath(void);
Guido van Rossum57d8e3f1997-07-19 19:50:52 +000080
81/* In their own files */
Fred Drake3cf4d2b2000-07-09 00:55:06 +000082DL_IMPORT(const char *) Py_GetVersion(void);
83DL_IMPORT(const char *) Py_GetPlatform(void);
84DL_IMPORT(const char *) Py_GetCopyright(void);
85DL_IMPORT(const char *) Py_GetCompiler(void);
86DL_IMPORT(const char *) Py_GetBuildInfo(void);
Guido van Rossum57d8e3f1997-07-19 19:50:52 +000087
Guido van Rossum29e46a91997-08-02 02:56:48 +000088/* Internal -- various one-time initializations */
Fred Drake3cf4d2b2000-07-09 00:55:06 +000089DL_IMPORT(PyObject *) _PyBuiltin_Init(void);
90DL_IMPORT(PyObject *) _PySys_Init(void);
91DL_IMPORT(void) _PyImport_Init(void);
92DL_IMPORT(void) init_exceptions(void);
Guido van Rossum29e46a91997-08-02 02:56:48 +000093
Guido van Rossum8e5e4461997-08-12 14:57:21 +000094/* Various internal finalizers */
Fred Drake3cf4d2b2000-07-09 00:55:06 +000095DL_IMPORT(void) fini_exceptions(void);
96DL_IMPORT(void) _PyImport_Fini(void);
97DL_IMPORT(void) PyMethod_Fini(void);
98DL_IMPORT(void) PyFrame_Fini(void);
99DL_IMPORT(void) PyCFunction_Fini(void);
100DL_IMPORT(void) PyTuple_Fini(void);
101DL_IMPORT(void) PyString_Fini(void);
102DL_IMPORT(void) PyInt_Fini(void);
103DL_IMPORT(void) PyFloat_Fini(void);
104DL_IMPORT(void) PyOS_FiniInterrupts(void);
Guido van Rossum8e5e4461997-08-12 14:57:21 +0000105
Guido van Rossum3fb1aea1997-08-12 15:14:22 +0000106/* Stuff with no proper home (yet) */
Fred Drake3cf4d2b2000-07-09 00:55:06 +0000107DL_IMPORT(char *) PyOS_Readline(char *);
108extern DL_IMPORT(int) (*PyOS_InputHook)(void);
109extern DL_IMPORT(char) *(*PyOS_ReadlineFunctionPointer)(char *);
Fredrik Lundh2f15b252000-08-27 19:15:31 +0000110
111/* Stack size, in "pointers" (so we get extra safety margins
112 on 64-bit platforms). On a 32-bit platform, this translates
113 to a 8k margin. */
114#define PYOS_STACK_MARGIN 2048
115
Trent Mick0a7af402000-10-11 17:18:11 +0000116#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER)
Fredrik Lundh2f15b252000-08-27 19:15:31 +0000117/* Enable stack checking under Microsoft C */
118#define USE_STACKCHECK
119#endif
120
Jack Jansen275abb32000-08-07 21:00:42 +0000121#ifdef USE_STACKCHECK
Fredrik Lundh2f15b252000-08-27 19:15:31 +0000122/* Check that we aren't overflowing our stack */
123DL_IMPORT(int) PyOS_CheckStack(void);
Jack Jansen275abb32000-08-07 21:00:42 +0000124#endif
Guido van Rossum3fb1aea1997-08-12 15:14:22 +0000125
Guido van Rossumc7247ce2000-09-16 16:31:31 +0000126/* Signals */
127typedef void (*PyOS_sighandler_t)(int);
128DL_IMPORT(PyOS_sighandler_t) PyOS_getsig(int);
129DL_IMPORT(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
130
131
Guido van Rossuma3309961993-07-28 09:05:47 +0000132#ifdef __cplusplus
133}
134#endif
135#endif /* !Py_PYTHONRUN_H */