blob: 89e8dd6a2850ca9709b95a5d7f8dcf8954999a26 [file] [log] [blame]
Guido van Rossumda5b8f22007-06-12 23:30:11 +00001/* File object interface (what's left of it -- see io.py) */
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00002
Fred Drakeea9cb5a2000-07-09 00:20:36 +00003#ifndef Py_FILEOBJECT_H
4#define Py_FILEOBJECT_H
5#ifdef __cplusplus
6extern "C" {
7#endif
8
Guido van Rossumda5b8f22007-06-12 23:30:11 +00009#define PY_STDIOTEXTMODE "b"
Martin v. Löwisf6eebbb2002-03-15 17:42:16 +000010
Serhiy Storchakac6792272013-10-19 21:03:34 +030011PyAPI_FUNC(PyObject *) PyFile_FromFd(int, const char *, const char *, int,
12 const char *, const char *,
13 const char *, int);
Mark Hammond91a681d2002-08-12 07:21:58 +000014PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
15PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
Mark Hammond91a681d2002-08-12 07:21:58 +000016PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
17PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000018#ifndef Py_LIMITED_API
Guido van Rossumda5b8f22007-06-12 23:30:11 +000019PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000020#endif
Guido van Rossuma3309961993-07-28 09:05:47 +000021
Mark Hammond26cffde42001-05-14 12:17:34 +000022/* The default encoding used by the platform file system APIs
Tim Peters058b1412002-04-21 07:29:14 +000023 If non-NULL, this is different than the default encoding for strings
Mark Hammond26cffde42001-05-14 12:17:34 +000024*/
Mark Hammond91a681d2002-08-12 07:21:58 +000025PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020026#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
Steve Dowercc16be82016-09-08 10:35:16 -070027PyAPI_DATA(const char *) Py_FileSystemDefaultEncodeErrors;
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020028#endif
Martin v. Löwis04dc25c2008-10-03 16:09:28 +000029PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding;
Mark Hammond26cffde42001-05-14 12:17:34 +000030
Victor Stinner91106cd2017-12-13 12:29:09 +010031#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
32PyAPI_DATA(int) Py_UTF8Mode;
33#endif
34
Guido van Rossum826d8972007-10-30 18:34:07 +000035/* Internal API
36
37 The std printer acts as a preliminary sys.stderr until the new io
38 infrastructure is in place. */
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000039#ifndef Py_LIMITED_API
Guido van Rossum826d8972007-10-30 18:34:07 +000040PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int);
41PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000042#endif /* Py_LIMITED_API */
Benjamin Petersonf91df042009-02-13 02:50:59 +000043
Charles-François Nataliaa26b272011-08-28 17:51:43 +020044/* A routine to check if a file descriptor can be select()-ed. */
Antoine Pitrouf474c5a2017-07-18 17:05:03 +020045#ifdef _MSC_VER
46 /* On Windows, any socket fd can be select()-ed, no matter how high */
47 #define _PyIsSelectable_fd(FD) (1)
Charles-François Nataliaa26b272011-08-28 17:51:43 +020048#else
Antoine Pitrouf474c5a2017-07-18 17:05:03 +020049 #define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE)
50#endif
Charles-François Nataliaa26b272011-08-28 17:51:43 +020051
Guido van Rossuma3309961993-07-28 09:05:47 +000052#ifdef __cplusplus
53}
54#endif
55#endif /* !Py_FILEOBJECT_H */