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