blob: 456887ef9d045da0e5fa3147554164cd01a70522 [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 *);
Guido van Rossuma3309961993-07-28 09:05:47 +000018
Mark Hammond26cffde42001-05-14 12:17:34 +000019/* The default encoding used by the platform file system APIs
Tim Peters058b1412002-04-21 07:29:14 +000020 If non-NULL, this is different than the default encoding for strings
Mark Hammond26cffde42001-05-14 12:17:34 +000021*/
Mark Hammond91a681d2002-08-12 07:21:58 +000022PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
Martin v. Löwis04dc25c2008-10-03 16:09:28 +000023PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding;
Mark Hammond26cffde42001-05-14 12:17:34 +000024
Charles-François Nataliaa26b272011-08-28 17:51:43 +020025/* A routine to check if a file descriptor can be select()-ed. */
Antoine Pitrouf474c5a2017-07-18 17:05:03 +020026#ifdef _MSC_VER
27 /* On Windows, any socket fd can be select()-ed, no matter how high */
28 #define _PyIsSelectable_fd(FD) (1)
Charles-François Nataliaa26b272011-08-28 17:51:43 +020029#else
Antoine Pitrouf474c5a2017-07-18 17:05:03 +020030 #define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE)
31#endif
Charles-François Nataliaa26b272011-08-28 17:51:43 +020032
Steve Dowerb82e17e2019-05-23 08:45:22 -070033#ifndef Py_LIMITED_API
34# define Py_CPYTHON_FILEOBJECT_H
35# include "cpython/fileobject.h"
36# undef Py_CPYTHON_FILEOBJECT_H
37#endif
38
Guido van Rossuma3309961993-07-28 09:05:47 +000039#ifdef __cplusplus
40}
41#endif
42#endif /* !Py_FILEOBJECT_H */