blob: 0939744e6d32080f328b888a7cc81b54be324f39 [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;
Martin v. Löwis04dc25c2008-10-03 16:09:28 +000026PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding;
Mark Hammond26cffde42001-05-14 12:17:34 +000027
Guido van Rossum826d8972007-10-30 18:34:07 +000028/* Internal API
29
30 The std printer acts as a preliminary sys.stderr until the new io
31 infrastructure is in place. */
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000032#ifndef Py_LIMITED_API
Guido van Rossum826d8972007-10-30 18:34:07 +000033PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int);
34PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
35
Benjamin Petersonf91df042009-02-13 02:50:59 +000036#if defined _MSC_VER && _MSC_VER >= 1400
37/* A routine to check if a file descriptor is valid on Windows. Returns 0
38 * and sets errno to EBADF if it isn't. This is to avoid Assertions
39 * from various functions in the Windows CRT beginning with
40 * Visual Studio 2005
41 */
42int _PyVerify_fd(int fd);
43#else
44#define _PyVerify_fd(A) (1) /* dummy */
45#endif
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000046#endif /* Py_LIMITED_API */
Benjamin Petersonf91df042009-02-13 02:50:59 +000047
Charles-François Nataliaa26b272011-08-28 17:51:43 +020048/* A routine to check if a file descriptor can be select()-ed. */
49#ifdef HAVE_SELECT
50 #define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE))
51#else
52 #define _PyIsSelectable_fd(FD) (1)
53#endif /* HAVE_SELECT */
54
Guido van Rossuma3309961993-07-28 09:05:47 +000055#ifdef __cplusplus
56}
57#endif
58#endif /* !Py_FILEOBJECT_H */