4 Copyright (c) 2015, Daryl McDaniel. All rights reserved.<BR>
5 Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef Py_FILEOBJECT_H
16 #define Py_FILEOBJECT_H
26 int (*f_close
)(FILE *);
27 int f_softspace
; /* Flag used by 'print' command */
28 int f_binary
; /* Flag which indicates whether the file is
29 open in binary (1) or text (0) mode */
30 char* f_buf
; /* Allocated readahead buffer */
31 char* f_bufend
; /* Points after last occupied position */
32 char* f_bufptr
; /* Current buffer position */
33 char *f_setbuf
; /* Buffer for setbuf(3) and setvbuf(3) */
34 int f_univ_newline
; /* Handle any newline convention */
35 int f_newlinetypes
; /* Types of newlines seen */
36 int f_skipnextlf
; /* Skip next \n */
39 PyObject
*weakreflist
; /* List of weak references */
40 int unlocked_count
; /* Num. currently running sections of code
41 using f_fp with the GIL released. */
46 PyAPI_DATA(PyTypeObject
) PyFile_Type
;
48 #define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type)
49 #define PyFile_CheckExact(op) (Py_TYPE(op) == &PyFile_Type)
51 PyAPI_FUNC(PyObject
*) PyFile_FromString(char *, char *);
52 PyAPI_FUNC(void) PyFile_SetBufSize(PyObject
*, int);
53 PyAPI_FUNC(int) PyFile_SetEncoding(PyObject
*, const char *);
54 PyAPI_FUNC(int) PyFile_SetEncodingAndErrors(PyObject
*, const char *, char *errors
);
55 PyAPI_FUNC(PyObject
*) PyFile_FromFile(FILE *, char *, char *,
57 PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject
*);
58 PyAPI_FUNC(void) PyFile_IncUseCount(PyFileObject
*);
59 PyAPI_FUNC(void) PyFile_DecUseCount(PyFileObject
*);
60 PyAPI_FUNC(PyObject
*) PyFile_Name(PyObject
*);
61 PyAPI_FUNC(PyObject
*) PyFile_GetLine(PyObject
*, int);
62 PyAPI_FUNC(int) PyFile_WriteObject(PyObject
*, PyObject
*, int);
63 PyAPI_FUNC(int) PyFile_SoftSpace(PyObject
*, int);
64 PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject
*);
65 PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject
*);
67 /* The default encoding used by the platform file system APIs
68 If non-NULL, this is different than the default encoding for strings
70 PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding
;
72 /* Routines to replace fread() and fgets() which accept any of \r, \n
73 or \r\n as line terminators.
75 #define PY_STDIOTEXTMODE "b"
76 char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject
*);
77 size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject
*);
79 /* A routine to do sanity checking on the file mode string. returns
80 non-zero on if an exception occurred
82 int _PyFile_SanitizeMode(char *mode
);
84 //#if defined _MSC_VER && _MSC_VER >= 1400
85 /* A routine to check if a file descriptor is valid on Windows. Returns 0
86 * and sets errno to EBADF if it isn't. This is to avoid Assertions
87 * from various functions in the Windows CRT beginning with
90 //int _PyVerify_fd(int fd);
91 //#elif defined _MSC_VER && _MSC_VER >= 1200
92 /* fdopen doesn't set errno EBADF and crashes for large fd on debug build */
93 //#define _PyVerify_fd(fd) (_get_osfhandle(fd) >= 0)
95 #define _PyVerify_fd(A) (1) /* dummy */
98 /* A routine to check if a file descriptor can be select()-ed. */
100 #define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE))
102 #define _PyIsSelectable_fd(FD) (1)
103 #endif /* HAVE_SELECT */
108 #endif /* !Py_FILEOBJECT_H */