FILE文件类型是标准C语言中用于指向文件的一个结构体,其内部结构会因为不同的编译器/操作系统发生不同的变化,对于Linux而言,其在stdio.h中进行定义
typedef struct _IO_FILE FILE;
其中结构体 _IO_FILE的定义在usr/inlucde/libio.h中
struct _IO_FILE {
272 int _flags; /* High-order word is _IO_MAGIC; rest is flags. */
273 #define _IO_file_flags _flags
274
275 /* The following pointers correspond to the C++ streambuf protocol. */
276 /* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */
277 char* _IO_read_ptr; /* Current read pointer */
278 char* _IO_read_end; /* End of get area. */
279 char* _IO_read_base; /* Start of putback+get area. */
280 char* _IO_write_base; /* Start of put area. */
281 char* _IO_write_ptr; /* Current put pointer. */
282 char* _IO_write_end; /* End of put area. */
283 char* _IO_buf_base; /* Start of reserve area. */
284 char* _IO_buf_end; /* End of reserve area. */
285 /* The following fields are used to support backing up and undo. */
286 char *_IO_save_base; /* Pointer to start of non-current get area. */
287 char *_IO_backup_base; /* Pointer to first valid character of backup area */
288 char *_IO_save_end; /* Pointer to end of non-current get area. */
289
290 struct _IO_marker *_markers;
291
292 struct _IO_FILE *_chain;
293
294 int _fileno;
295 #if 0
296 int _blksize;
297 #else
298 int _flags2;
299 #endif
300 _IO_off_t _old_offset; /* This used to be _offset but it‘s too small. */
301
302 #define __HAVE_COLUMN /* temporary */
303 /* 1+column number of pbase(); 0 is unknown. */
304 unsigned short _cur_column;
305 signed char _vtable_offset;
306 char _shortbuf[1];
307
308 /* char* _save_gptr; char* _save_egptr; */
309
310 _IO_lock_t *_lock;
311 #ifdef _IO_USE_OLD_IO_FILE
312 };
272 int _flags; /* High-order word is _IO_MAGIC; rest is flags. */
273 #define _IO_file_flags _flags
274
275 /* The following pointers correspond to the C++ streambuf protocol. */
276 /* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */
277 char* _IO_read_ptr; /* Current read pointer */
278 char* _IO_read_end; /* End of get area. */
279 char* _IO_read_base; /* Start of putback+get area. */
280 char* _IO_write_base; /* Start of put area. */
281 char* _IO_write_ptr; /* Current put pointer. */
282 char* _IO_write_end; /* End of put area. */
283 char* _IO_buf_base; /* Start of reserve area. */
284 char* _IO_buf_end; /* End of reserve area. */
285 /* The following fields are used to support backing up and undo. */
286 char *_IO_save_base; /* Pointer to start of non-current get area. */
287 char *_IO_backup_base; /* Pointer to first valid character of backup area */
288 char *_IO_save_end; /* Pointer to end of non-current get area. */
289
290 struct _IO_marker *_markers;
291
292 struct _IO_FILE *_chain;
293
294 int _fileno;
295 #if 0
296 int _blksize;
297 #else
298 int _flags2;
299 #endif
300 _IO_off_t _old_offset; /* This used to be _offset but it‘s too small. */
301
302 #define __HAVE_COLUMN /* temporary */
303 /* 1+column number of pbase(); 0 is unknown. */
304 unsigned short _cur_column;
305 signed char _vtable_offset;
306 char _shortbuf[1];
307
308 /* char* _save_gptr; char* _save_egptr; */
309
310 _IO_lock_t *_lock;
311 #ifdef _IO_USE_OLD_IO_FILE
312 };