1
/**********************************************************************
6
$Date: 2007-08-25 12:29:39 +0900 (土, 25 8月 2007) $
7
created at: Fri Nov 12 16:47:09 JST 1993
9
Copyright (C) 1993-2007 Yukihiro Matsumoto
11
**********************************************************************/
16
#if defined(__cplusplus)
19
} /* satisfy cc-mode */
25
#include "ruby/encoding.h"
27
#if defined(HAVE_STDIO_EXT_H)
28
#include <stdio_ext.h>
31
typedef struct rb_io_t {
32
int fd; /* file descriptor */
33
FILE *stdio_file; /* stdio ptr for read/write if available */
34
int mode; /* mode flags */
35
rb_pid_t pid; /* child's pid (for pipes) */
36
int lineno; /* number of lines read */
37
char *path; /* pathname for file */
38
void (*finalize)(struct rb_io_t*,int); /* finalize proc */
40
char *wbuf; /* wbuf_off + wbuf_len <= wbuf_capa */
44
char *rbuf; /* rbuf_off + rbuf_len <= rbuf_capa */
51
#define HAVE_RB_IO_T 1
53
#define FMODE_READABLE 1
54
#define FMODE_WRITABLE 2
55
#define FMODE_READWRITE 3
56
#define FMODE_APPEND 64
57
#define FMODE_CREATE 128
58
#define FMODE_BINMODE 4
61
#define FMODE_DUPLEX 32
62
#define FMODE_WSPLIT 0x200
63
#define FMODE_WSPLIT_INITIALIZED 0x400
65
#define GetOpenFile(obj,fp) rb_io_check_closed((fp) = RFILE(rb_io_taint_check(obj))->fptr)
67
#define MakeOpenFile(obj, fp) do {\
68
if (RFILE(obj)->fptr) {\
70
free(RFILE(obj)->fptr);\
71
RFILE(obj)->fptr = 0;\
74
fp = RFILE(obj)->fptr = ALLOC(rb_io_t);\
76
fp->stdio_file = NULL;\
93
FILE *rb_io_stdio_file(rb_io_t *fptr);
95
FILE *rb_fopen(const char*, const char*);
96
FILE *rb_fdopen(int, const char*);
97
int rb_io_mode_flags(const char*);
98
int rb_io_modenum_flags(int);
99
void rb_io_check_writable(rb_io_t*);
100
void rb_io_check_readable(rb_io_t*);
101
int rb_io_fptr_finalize(rb_io_t*);
102
void rb_io_synchronized(rb_io_t*);
103
void rb_io_check_initialized(rb_io_t*);
104
void rb_io_check_closed(rb_io_t*);
105
int rb_io_wait_readable(int);
106
int rb_io_wait_writable(int);
107
void rb_io_set_nonblock(rb_io_t *fptr);
109
VALUE rb_io_taint_check(VALUE);
110
NORETURN(void rb_eof_error(void));
112
void rb_io_read_check(rb_io_t*);
113
int rb_io_read_pending(rb_io_t*);
114
void rb_read_check(FILE*);
116
DEPRECATED(int rb_getc(FILE*));
117
DEPRECATED(long rb_io_fread(char *, long, FILE *));
118
DEPRECATED(long rb_io_fwrite(const char *, long, FILE *));
119
DEPRECATED(int rb_read_pending(FILE*));
121
#if defined(__cplusplus)
123
{ /* satisfy cc-mode */
128
#endif /* RUBY_IO_H */