Guido van Rossum | da5b8f2 | 2007-06-12 23:30:11 +0000 | [diff] [blame] | 1 | /* File object interface (what's left of it -- see io.py) */ |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 2 | |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 3 | #ifndef Py_FILEOBJECT_H |
| 4 | #define Py_FILEOBJECT_H |
| 5 | #ifdef __cplusplus |
| 6 | extern "C" { |
| 7 | #endif |
| 8 | |
Guido van Rossum | da5b8f2 | 2007-06-12 23:30:11 +0000 | [diff] [blame] | 9 | #define PY_STDIOTEXTMODE "b" |
Martin v. Löwis | f6eebbb | 2002-03-15 17:42:16 +0000 | [diff] [blame] | 10 | |
Serhiy Storchaka | c679227 | 2013-10-19 21:03:34 +0300 | [diff] [blame] | 11 | PyAPI_FUNC(PyObject *) PyFile_FromFd(int, const char *, const char *, int, |
| 12 | const char *, const char *, |
| 13 | const char *, int); |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 14 | PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); |
| 15 | PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 16 | PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); |
| 17 | PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *); |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 18 | #ifndef Py_LIMITED_API |
Guido van Rossum | da5b8f2 | 2007-06-12 23:30:11 +0000 | [diff] [blame] | 19 | PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *); |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 20 | #endif |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 21 | |
Mark Hammond | 26cffde4 | 2001-05-14 12:17:34 +0000 | [diff] [blame] | 22 | /* The default encoding used by the platform file system APIs |
Tim Peters | 058b141 | 2002-04-21 07:29:14 +0000 | [diff] [blame] | 23 | If non-NULL, this is different than the default encoding for strings |
Mark Hammond | 26cffde4 | 2001-05-14 12:17:34 +0000 | [diff] [blame] | 24 | */ |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 25 | PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding; |
Serhiy Storchaka | 34d0ac8 | 2016-12-27 14:57:39 +0200 | [diff] [blame] | 26 | #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000 |
Steve Dower | cc16be8 | 2016-09-08 10:35:16 -0700 | [diff] [blame] | 27 | PyAPI_DATA(const char *) Py_FileSystemDefaultEncodeErrors; |
Serhiy Storchaka | 34d0ac8 | 2016-12-27 14:57:39 +0200 | [diff] [blame] | 28 | #endif |
Martin v. Löwis | 04dc25c | 2008-10-03 16:09:28 +0000 | [diff] [blame] | 29 | PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding; |
Mark Hammond | 26cffde4 | 2001-05-14 12:17:34 +0000 | [diff] [blame] | 30 | |
Victor Stinner | 91106cd | 2017-12-13 12:29:09 +0100 | [diff] [blame] | 31 | #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000 |
| 32 | PyAPI_DATA(int) Py_UTF8Mode; |
| 33 | #endif |
| 34 | |
Guido van Rossum | 826d897 | 2007-10-30 18:34:07 +0000 | [diff] [blame] | 35 | /* 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öwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 39 | #ifndef Py_LIMITED_API |
Guido van Rossum | 826d897 | 2007-10-30 18:34:07 +0000 | [diff] [blame] | 40 | PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int); |
| 41 | PyAPI_DATA(PyTypeObject) PyStdPrinter_Type; |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 42 | #endif /* Py_LIMITED_API */ |
Benjamin Peterson | f91df04 | 2009-02-13 02:50:59 +0000 | [diff] [blame] | 43 | |
Charles-François Natali | aa26b27 | 2011-08-28 17:51:43 +0200 | [diff] [blame] | 44 | /* A routine to check if a file descriptor can be select()-ed. */ |
Antoine Pitrou | f474c5a | 2017-07-18 17:05:03 +0200 | [diff] [blame] | 45 | #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 Natali | aa26b27 | 2011-08-28 17:51:43 +0200 | [diff] [blame] | 48 | #else |
Antoine Pitrou | f474c5a | 2017-07-18 17:05:03 +0200 | [diff] [blame] | 49 | #define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE) |
| 50 | #endif |
Charles-François Natali | aa26b27 | 2011-08-28 17:51:43 +0200 | [diff] [blame] | 51 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 52 | #ifdef __cplusplus |
| 53 | } |
| 54 | #endif |
| 55 | #endif /* !Py_FILEOBJECT_H */ |