Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | #ifndef Py_FILEOBJECT_H |
2 | #define Py_FILEOBJECT_H | |
3 | #ifdef __cplusplus | |
4 | extern "C" { | |
5 | #endif | |
6 | ||
7 | typedef struct { | |
8 | PyObject_HEAD | |
9 | FILE *f_fp; | |
10 | PyObject *f_name; | |
11 | PyObject *f_mode; | |
12 | int (*f_close)(FILE *); | |
13 | int f_softspace; /* Flag used by 'print' command */ | |
14 | int f_binary; /* Flag which indicates whether the file is | |
15 | open in binary (1) or text (0) mode */ | |
16 | char* f_buf; /* Allocated readahead buffer */ | |
17 | char* f_bufend; /* Points after last occupied position */ | |
18 | char* f_bufptr; /* Current buffer position */ | |
19 | char *f_setbuf; /* Buffer for setbuf(3) and setvbuf(3) */ | |
20 | int f_univ_newline; /* Handle any newline convention */ | |
21 | int f_newlinetypes; /* Types of newlines seen */ | |
22 | int f_skipnextlf; /* Skip next \n */ | |
23 | PyObject *f_encoding; | |
24 | PyObject *weakreflist; /* List of weak references */ | |
25 | } PyFileObject; | |
26 | ||
27 | PyAPI_DATA(PyTypeObject) PyFile_Type; | |
28 | ||
29 | #define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type) | |
30 | #define PyFile_CheckExact(op) ((op)->ob_type == &PyFile_Type) | |
31 | ||
32 | PyAPI_FUNC(PyObject *) PyFile_FromString(char *, char *); | |
33 | PyAPI_FUNC(void) PyFile_SetBufSize(PyObject *, int); | |
34 | PyAPI_FUNC(int) PyFile_SetEncoding(PyObject *, const char *); | |
35 | PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *, | |
36 | int (*)(FILE *)); | |
37 | PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *); | |
38 | PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *); | |
39 | PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); | |
40 | PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); | |
41 | PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int); | |
42 | PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); | |
43 | PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *); | |
44 | ||
45 | /* The default encoding used by the platform file system APIs | |
46 | If non-NULL, this is different than the default encoding for strings | |
47 | */ | |
48 | PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding; | |
49 | ||
50 | /* Routines to replace fread() and fgets() which accept any of \r, \n | |
51 | or \r\n as line terminators. | |
52 | */ | |
53 | #define PY_STDIOTEXTMODE "b" | |
54 | char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *); | |
55 | size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject *); | |
56 | ||
57 | #ifdef __cplusplus | |
58 | } | |
59 | #endif | |
60 | #endif /* !Py_FILEOBJECT_H */ |