blob: 6e0e55e3eec4a6d0241c3fe3248e3b7da7945fd4 [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
Guido van Rossum2dced8b2007-10-30 17:27:30 +000011PyAPI_FUNC(PyObject *) PyFile_FromFd(int, char *, char *, int, char *, char *,
Guido van Rossume7fc50f2007-12-03 22:54:21 +000012 char *, int);
Mark Hammond91a681d2002-08-12 07:21:58 +000013PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
14PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
Mark Hammond91a681d2002-08-12 07:21:58 +000015PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
16PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
Guido van Rossumda5b8f22007-06-12 23:30:11 +000017PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, 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;
24PyAPI_FUNC(int) _Py_SetFileSystemEncoding(PyObject *);
Mark Hammond26cffde42001-05-14 12:17:34 +000025
Guido van Rossum826d8972007-10-30 18:34:07 +000026/* Internal API
27
28 The std printer acts as a preliminary sys.stderr until the new io
29 infrastructure is in place. */
30PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int);
31PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
32
Benjamin Petersonf91df042009-02-13 02:50:59 +000033#if defined _MSC_VER && _MSC_VER >= 1400
34/* A routine to check if a file descriptor is valid on Windows. Returns 0
35 * and sets errno to EBADF if it isn't. This is to avoid Assertions
36 * from various functions in the Windows CRT beginning with
37 * Visual Studio 2005
38 */
39int _PyVerify_fd(int fd);
40#else
41#define _PyVerify_fd(A) (1) /* dummy */
42#endif
43
Guido van Rossuma3309961993-07-28 09:05:47 +000044#ifdef __cplusplus
45}
46#endif
47#endif /* !Py_FILEOBJECT_H */