| 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 |  | 
| Guido van Rossum | 2dced8b | 2007-10-30 17:27:30 +0000 | [diff] [blame] | 11 | PyAPI_FUNC(PyObject *) PyFile_FromFd(int, char *, char *, int, char *, char *, | 
| Guido van Rossum | e7fc50f | 2007-12-03 22:54:21 +0000 | [diff] [blame] | 12 | 				     char *, int); | 
| Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 13 | PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); | 
 | 14 | PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); | 
| Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 15 | PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); | 
 | 16 | PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *); | 
| Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 17 | #ifndef Py_LIMITED_API | 
| Guido van Rossum | da5b8f2 | 2007-06-12 23:30:11 +0000 | [diff] [blame] | 18 | PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *); | 
| Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 19 | #endif | 
| Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 20 |  | 
| Mark Hammond | 26cffde | 2001-05-14 12:17:34 +0000 | [diff] [blame] | 21 | /* The default encoding used by the platform file system APIs | 
| Tim Peters | 058b141 | 2002-04-21 07:29:14 +0000 | [diff] [blame] | 22 |    If non-NULL, this is different than the default encoding for strings | 
| Mark Hammond | 26cffde | 2001-05-14 12:17:34 +0000 | [diff] [blame] | 23 | */ | 
| Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 24 | PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding; | 
| Martin v. Löwis | 04dc25c | 2008-10-03 16:09:28 +0000 | [diff] [blame] | 25 | PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding; | 
| Mark Hammond | 26cffde | 2001-05-14 12:17:34 +0000 | [diff] [blame] | 26 |  | 
| Guido van Rossum | 826d897 | 2007-10-30 18:34:07 +0000 | [diff] [blame] | 27 | /* Internal API | 
 | 28 |  | 
 | 29 |    The std printer acts as a preliminary sys.stderr until the new io | 
 | 30 |    infrastructure is in place. */ | 
| Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 31 | #ifndef Py_LIMITED_API | 
| Guido van Rossum | 826d897 | 2007-10-30 18:34:07 +0000 | [diff] [blame] | 32 | PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int); | 
 | 33 | PyAPI_DATA(PyTypeObject) PyStdPrinter_Type; | 
 | 34 |  | 
| Benjamin Peterson | f91df04 | 2009-02-13 02:50:59 +0000 | [diff] [blame] | 35 | #if defined _MSC_VER && _MSC_VER >= 1400 | 
 | 36 | /* A routine to check if a file descriptor is valid on Windows.  Returns 0 | 
 | 37 |  * and sets errno to EBADF if it isn't.  This is to avoid Assertions | 
 | 38 |  * from various functions in the Windows CRT beginning with | 
 | 39 |  * Visual Studio 2005 | 
 | 40 |  */ | 
 | 41 | int _PyVerify_fd(int fd); | 
 | 42 | #else | 
 | 43 | #define _PyVerify_fd(A) (1) /* dummy */ | 
 | 44 | #endif | 
| Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 45 | #endif /* Py_LIMITED_API */ | 
| Benjamin Peterson | f91df04 | 2009-02-13 02:50:59 +0000 | [diff] [blame] | 46 |  | 
| Charles-François Natali | aa26b27 | 2011-08-28 17:51:43 +0200 | [diff] [blame] | 47 | /* A routine to check if a file descriptor can be select()-ed. */ | 
 | 48 | #ifdef HAVE_SELECT | 
 | 49 |  #define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE)) | 
 | 50 | #else | 
 | 51 |  #define _PyIsSelectable_fd(FD) (1) | 
 | 52 | #endif /* HAVE_SELECT */ | 
 | 53 |  | 
| Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 54 | #ifdef __cplusplus | 
 | 55 | } | 
 | 56 | #endif | 
 | 57 | #endif /* !Py_FILEOBJECT_H */ |