fileobject.h 1.73 KB
Newer Older
1
/* File object interface (what's left of it -- see io.py) */
Guido van Rossum's avatar
Guido van Rossum committed
2

3 4 5 6 7 8
#ifndef Py_FILEOBJECT_H
#define Py_FILEOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif

9
#define PY_STDIOTEXTMODE "b"
Guido van Rossum's avatar
Guido van Rossum committed
10

11
PyAPI_FUNC(PyObject *) PyFile_FromFd(int, char *, char *, int, char *, char *,
12
				     char *, int);
13 14 15 16
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
17
#ifndef Py_LIMITED_API
18
PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
19
#endif
20

21
/* The default encoding used by the platform file system APIs
22
   If non-NULL, this is different than the default encoding for strings
23
*/
24
PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
25
PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding;
26

27 28 29 30
/* Internal API

   The std printer acts as a preliminary sys.stderr until the new io
   infrastructure is in place. */
31
#ifndef Py_LIMITED_API
32 33 34
PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int);
PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;

Benjamin Peterson's avatar
Benjamin Peterson committed
35 36 37 38 39 40 41 42 43 44
#if defined _MSC_VER && _MSC_VER >= 1400
/* A routine to check if a file descriptor is valid on Windows.  Returns 0
 * and sets errno to EBADF if it isn't.  This is to avoid Assertions
 * from various functions in the Windows CRT beginning with
 * Visual Studio 2005
 */
int _PyVerify_fd(int fd);
#else
#define _PyVerify_fd(A) (1) /* dummy */
#endif
45
#endif /* Py_LIMITED_API */
Benjamin Peterson's avatar
Benjamin Peterson committed
46

47 48 49 50 51 52 53
/* A routine to check if a file descriptor can be select()-ed. */
#ifdef HAVE_SELECT
 #define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE))
#else
 #define _PyIsSelectable_fd(FD) (1)
#endif /* HAVE_SELECT */

54 55 56 57
#ifdef __cplusplus
}
#endif
#endif /* !Py_FILEOBJECT_H */