1
/**********************************************************************
6
$Date: 2007-02-25 10:16:58 +0900 (日, 25 2月 2007) $
7
created at: Fri Nov 12 16:47:09 JST 1993
9
Copyright (C) 1993-2003 Yukihiro Matsumoto
11
**********************************************************************/
19
#if defined(HAVE_STDIO_EXT_H)
20
#include <stdio_ext.h>
23
typedef struct rb_io_t {
24
int fd; /* file descriptor */
25
FILE *stdio_file; /* stdio ptr for read/write if available */
26
int mode; /* mode flags */
27
rb_pid_t pid; /* child's pid (for pipes) */
28
int lineno; /* number of lines read */
29
char *path; /* pathname for file */
30
void (*finalize)(struct rb_io_t*,int); /* finalize proc */
32
char *wbuf; /* wbuf_off + wbuf_len <= wbuf_capa */
36
char *rbuf; /* rbuf_off + rbuf_len <= rbuf_capa */
42
#define HAVE_RB_IO_T 1
44
#define FMODE_READABLE 1
45
#define FMODE_WRITABLE 2
46
#define FMODE_READWRITE 3
47
#define FMODE_APPEND 64
48
#define FMODE_CREATE 128
49
#define FMODE_BINMODE 4
52
#define FMODE_DUPLEX 32
53
#define FMODE_WSPLIT 0x200
54
#define FMODE_WSPLIT_INITIALIZED 0x400
56
#define GetOpenFile(obj,fp) rb_io_check_closed((fp) = RFILE(rb_io_taint_check(obj))->fptr)
58
#define MakeOpenFile(obj, fp) do {\
59
if (RFILE(obj)->fptr) {\
61
free(RFILE(obj)->fptr);\
62
RFILE(obj)->fptr = 0;\
65
fp = RFILE(obj)->fptr = ALLOC(rb_io_t);\
67
fp->stdio_file = NULL;\
84
FILE *rb_io_stdio_file(rb_io_t *fptr);
86
FILE *rb_fopen(const char*, const char*);
87
FILE *rb_fdopen(int, const char*);
88
int rb_io_mode_flags(const char*);
89
int rb_io_modenum_flags(int);
90
void rb_io_check_writable(rb_io_t*);
91
void rb_io_check_readable(rb_io_t*);
92
int rb_io_fptr_finalize(rb_io_t*);
93
void rb_io_synchronized(rb_io_t*);
94
void rb_io_check_initialized(rb_io_t*);
95
void rb_io_check_closed(rb_io_t*);
96
int rb_io_wait_readable(int);
97
int rb_io_wait_writable(int);
98
void rb_io_set_nonblock(rb_io_t *fptr);
100
VALUE rb_io_taint_check(VALUE);
101
NORETURN(void rb_eof_error(void));
103
void rb_io_read_check(rb_io_t*);
104
int rb_io_read_pending(rb_io_t*);
105
void rb_read_check(FILE*);
107
DEPRECATED(int rb_getc(FILE*));
108
DEPRECATED(long rb_io_fread(char *, long, FILE *));
109
DEPRECATED(long rb_io_fwrite(const char *, long, FILE *));
110
DEPRECATED(int rb_read_pending(FILE*));