Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
io.c File Reference
#include "internal.h"
#include "ruby/io.h"
#include "ruby/thread.h"
#include "dln.h"
#include "encindex.h"
#include "id.h"
#include <ctype.h>
#include <errno.h>
#include "ruby_atomic.h"
#include <sys/types.h>
#include <sys/stat.h>
#include "ruby/util.h"

Go to the source code of this file.

Data Structures

struct  argf
 
struct  io_internal_read_struct
 
struct  io_internal_write_struct
 
struct  binwrite_arg
 
struct  write_arg
 
struct  bufread_arg
 
struct  read_internal_arg
 
struct  getline_arg
 
struct  finish_writeconv_arg
 
struct  sysopen_struct
 
struct  pipe_list
 
struct  rb_f_p_arg
 
struct  select_args
 
struct  io_encoding_set_args
 
struct  foreach_arg
 
struct  seek_arg
 
struct  copy_stream_struct
 
struct  argf_call_arg
 

Macros

#define free(x)   xfree(x)
 
#define off_t   long
 
#define NOFILE   64
 
#define O_ACCMODE   (O_RDONLY | O_WRONLY | O_RDWR)
 
#define PIPE_BUF   512 /* is this ok? */
 
#define EWOULDBLOCK   EAGAIN
 
#define IO_RBUF_CAPA_MIN   8192
 
#define IO_CBUF_CAPA_MIN   (128*1024)
 
#define IO_RBUF_CAPA_FOR(fptr)   (NEED_READCONV(fptr) ? IO_CBUF_CAPA_MIN : IO_RBUF_CAPA_MIN)
 
#define IO_WBUF_CAPA_MIN   8192
 
#define id_exception   idException
 
#define argf_of(obj)   (*(struct argf *)DATA_PTR(obj))
 
#define ARGF   argf_of(argf)
 
#define GetWriteIO(io)   rb_io_get_write_io(io)
 
#define READ_DATA_PENDING(fptr)   ((fptr)->rbuf.len)
 
#define READ_DATA_PENDING_COUNT(fptr)   ((fptr)->rbuf.len)
 
#define READ_DATA_PENDING_PTR(fptr)   ((fptr)->rbuf.ptr+(fptr)->rbuf.off)
 
#define READ_DATA_BUFFERED(fptr)   READ_DATA_PENDING(fptr)
 
#define READ_CHAR_PENDING(fptr)   ((fptr)->cbuf.len)
 
#define READ_CHAR_PENDING_COUNT(fptr)   ((fptr)->cbuf.len)
 
#define READ_CHAR_PENDING_PTR(fptr)   ((fptr)->cbuf.ptr+(fptr)->cbuf.off)
 
#define WAIT_FD_IN_WIN32(fptr)
 
#define READ_CHECK(fptr)
 
#define NEED_NEWLINE_DECORATOR_ON_READ(fptr)   ((fptr)->mode & FMODE_TEXTMODE)
 
#define NEED_NEWLINE_DECORATOR_ON_WRITE(fptr)   ((fptr)->mode & FMODE_TEXTMODE)
 
#define DEFAULT_TEXTMODE   0
 
#define NEED_READCONV(fptr)   ((fptr)->encs.enc2 != NULL || NEED_NEWLINE_DECORATOR_ON_READ(fptr))
 
#define NEED_WRITECONV(fptr)   (((fptr)->encs.enc != NULL && (fptr)->encs.enc != rb_ascii8bit_encoding()) || NEED_NEWLINE_DECORATOR_ON_WRITE(fptr) || ((fptr)->encs.ecflags & (ECONV_DECORATOR_MASK|ECONV_STATEFUL_DECORATOR_MASK)))
 
#define SET_BINARY_MODE(fptr)   (void)(fptr)
 
#define NEED_NEWLINE_DECORATOR_ON_READ_CHECK(fptr)   (void)(fptr)
 
#define SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2(enc2, ecflags)   ((void)(enc2), (void)(ecflags))
 
#define SET_BINARY_MODE_WITH_SEEK_CUR(fptr)   (void)(fptr)
 
#define shutdown(a, b)   0
 
#define is_socket(fd, path)   0
 
#define io_seek(fptr, ofs, whence)   (errno = 0, lseek(flush_before_seek(fptr)->fd, (ofs), (whence)))
 
#define io_tell(fptr)   lseek(flush_before_seek(fptr)->fd, 0, SEEK_CUR)
 
#define SEEK_SET   0
 
#define SEEK_CUR   1
 
#define SEEK_END   2
 
#define S_ISREG(m)   (((m) & S_IFMT) == S_IFREG)
 
#define MODE_BTMODE(a, b, c)
 
#define fmode   (fptr->mode)
 
#define rb_io_fsync   rb_f_notimplement
 
#define rb_io_sync   rb_f_notimplement
 
#define rb_io_fdatasync   rb_io_fsync
 
#define MORE_CHAR_SUSPENDED   Qtrue
 
#define MORE_CHAR_FINISHED   Qnil
 
#define MAX_REALLOC_GAP   4096
 
#define rb_io_close_on_exec_p   rb_f_notimplement
 
#define rb_io_set_close_on_exec   rb_f_notimplement
 
#define FMODE_PREP   (1<<16)
 
#define IS_PREP_STDIO(f)   ((f)->mode & FMODE_PREP)
 
#define PREP_STDIO_NAME(f)   (RSTRING_PTR((f)->pathv))
 
#define KEEPGVL   FALSE
 
#define SHUT_RD   0
 
#define SHUT_WR   1
 
#define rb_io_pread   rb_f_notimplement
 
#define rb_io_pwrite   rb_f_notimplement
 
#define MODE_BINARY(a, b)   (a)
 
#define next_argv()   argf_next_argv(argf)
 
#define ARGF_GENERIC_INPUT_P()   (ARGF.current_file == rb_stdin && !RB_TYPE_P(ARGF.current_file, T_FILE))
 
#define ARGF_FORWARD(argc, argv)
 
#define NEXT_ARGF_FORWARD(argc, argv)
 
#define NUM2IOCTLREQ(num)   NUM2INT(num)
 
#define DEFULT_IOCTL_NARG_LEN   (256)
 
#define rb_io_ioctl   rb_f_notimplement
 
#define rb_io_fcntl   rb_f_notimplement
 
#define rb_f_syscall   rb_f_notimplement
 
#define IOWAIT_SYSCALL   "select"
 
#define USE_POLL   0
 
#define FOREACH_ARGF()   while (next_argv())
 
#define rb_intern(str)   rb_intern_const(str)
 

Typedefs

typedef struct rb_io_enc_t convconfig_t
 
typedef int ioctl_req_t
 

Enumerations

enum  { bom_prefix_len = (int)sizeof(bom_prefix) - 1 }
 
enum  { utf_prefix_len = (int)sizeof(utf_prefix) - 1 }
 

Functions

void rb_update_max_fd (int fd)
 
void rb_maygvl_fd_fix_cloexec (int fd)
 
void rb_fd_fix_cloexec (int fd)
 
int rb_cloexec_open (const char *pathname, int flags, mode_t mode)
 
int rb_cloexec_dup (int oldfd)
 
int rb_cloexec_dup2 (int oldfd, int newfd)
 
int rb_cloexec_pipe (int fildes[2])
 
int rb_cloexec_fcntl_dupfd (int fd, int minfd)
 
void rb_eof_error (void)
 
VALUE rb_io_taint_check (VALUE io)
 
void rb_io_check_initialized (rb_io_t *fptr)
 
void rb_io_check_closed (rb_io_t *fptr)
 
VALUE rb_io_get_io (VALUE io)
 
VALUE rb_io_check_io (VALUE io)
 
VALUE rb_io_get_write_io (VALUE io)
 
VALUE rb_io_set_write_io (VALUE io, VALUE w)
 
void rb_io_check_char_readable (rb_io_t *fptr)
 
void rb_io_check_byte_readable (rb_io_t *fptr)
 
void rb_io_check_readable (rb_io_t *fptr)
 
void rb_io_check_writable (rb_io_t *fptr)
 
int rb_io_read_pending (rb_io_t *fptr)
 
void rb_io_read_check (rb_io_t *fptr)
 
int rb_gc_for_fd (int err)
 
int rb_io_wait_readable (int f)
 
int rb_io_wait_writable (int f)
 
ssize_t rb_io_bufwrite (VALUE io, const void *buf, size_t size)
 
VALUE rb_io_write (VALUE io, VALUE str)
 
VALUE rb_io_addstr (VALUE io, VALUE str)
 
VALUE rb_io_flush_raw (VALUE io, int sync)
 
VALUE rb_io_flush (VALUE io)
 
VALUE rb_io_eof (VALUE io)
 
ssize_t rb_io_bufread (VALUE io, void *buf, size_t size)
 
void rb_io_set_nonblock (rb_io_t *fptr)
 
VALUE rb_io_gets (VALUE io)
 
VALUE rb_io_gets_internal (VALUE io)
 
VALUE rb_io_getbyte (VALUE io)
 
VALUE rb_io_ungetbyte (VALUE io, VALUE b)
 
VALUE rb_io_ungetc (VALUE io, VALUE c)
 
int rb_io_fptr_finalize (rb_io_t *fptr)
 
RUBY_FUNC_EXPORTED size_t rb_io_memsize (const rb_io_t *fptr)
 
int rb_notify_fd_close (int fd)
 
VALUE rb_io_close (VALUE io)
 
VALUE rb_io_binmode (VALUE io)
 
VALUE rb_io_ascii8bit_binmode (VALUE io)
 
int rb_io_modestr_fmode (const char *modestr)
 
int rb_io_oflags_fmode (int oflags)
 
int rb_io_modestr_oflags (const char *modestr)
 
int rb_io_extract_encoding_option (VALUE opt, rb_encoding **enc_p, rb_encoding **enc2_p, int *fmode_p)
 
FILErb_fdopen (int fd, const char *modestr)
 
VALUE rb_file_open_str (VALUE fname, const char *modestr)
 
VALUE rb_file_open (const char *fname, const char *modestr)
 
void rb_io_synchronized (rb_io_t *fptr)
 
void rb_io_unbuffered (rb_io_t *fptr)
 
int rb_pipe (int *pipes)
 
char * rb_execarg_commandline (const struct rb_execarg *eargp, VALUE *prog)
 
VALUE rb_io_printf (int argc, const VALUE *argv, VALUE out)
 
VALUE rb_io_print (int argc, const VALUE *argv, VALUE out)
 
int rb_str_end_with_asciichar (VALUE str, int c)
 
VALUE rb_io_puts (int argc, const VALUE *argv, VALUE out)
 
void rb_p (VALUE obj)
 
void rb_write_error2 (const char *mesg, long len)
 
void rb_write_error (const char *mesg)
 
void rb_write_error_str (VALUE mesg)
 
int rb_stderr_tty_p (void)
 
VALUE rb_io_fdopen (int fd, int oflags, const char *path)
 
FILErb_io_stdio_file (rb_io_t *fptr)
 
rb_io_trb_io_make_open_file (VALUE obj)
 
VALUE rb_gets (void)
 
void rb_stdio_set_default_encoding (void)
 
const char * ruby_get_inplace_mode (void)
 
void ruby_set_inplace_mode (const char *suffix)
 
VALUE rb_get_argv (void)
 
void rb_readwrite_sys_fail (enum rb_io_wait_readwrite writable, const char *mesg)
 
void rb_readwrite_syserr_fail (enum rb_io_wait_readwrite writable, int n, const char *mesg)
 
void Init_IO (void)
 

Variables

VALUE rb_cIO
 
VALUE rb_eEOFError
 
VALUE rb_eIOError
 
VALUE rb_mWaitReadable
 
VALUE rb_mWaitWritable
 
VALUE rb_stdin
 
VALUE rb_stdout
 
VALUE rb_stderr
 
VALUE rb_output_fs
 
VALUE rb_rs
 
VALUE rb_output_rs
 
VALUE rb_default_rs
 

Macro Definition Documentation

◆ ARGF

#define ARGF   argf_of(argf)

Definition at line 405 of file io.c.

Referenced by rb_get_argv(), ruby_get_inplace_mode(), and ruby_set_inplace_mode().

◆ ARGF_FORWARD

#define ARGF_FORWARD (   argc,
  argv 
)
Value:
do {\
return argf_forward((argc), (argv), argf);\
} while (0)
Definition: io.c:179
#define ARGF_GENERIC_INPUT_P()
Definition: io.c:8186
int argc
Definition: ruby.c:187
char ** argv
Definition: ruby.c:188

Definition at line 8188 of file io.c.

◆ ARGF_GENERIC_INPUT_P

#define ARGF_GENERIC_INPUT_P ( )    (ARGF.current_file == rb_stdin && !RB_TYPE_P(ARGF.current_file, T_FILE))

Definition at line 8186 of file io.c.

◆ argf_of

#define argf_of (   obj)    (*(struct argf *)DATA_PTR(obj))

Definition at line 404 of file io.c.

◆ DEFAULT_TEXTMODE

#define DEFAULT_TEXTMODE   0

Definition at line 589 of file io.c.

◆ DEFULT_IOCTL_NARG_LEN

#define DEFULT_IOCTL_NARG_LEN   (256)

Definition at line 9210 of file io.c.

◆ EWOULDBLOCK

#define EWOULDBLOCK   EAGAIN

Definition at line 115 of file io.c.

◆ fmode

#define fmode   (fptr->mode)

Referenced by rb_io_oflags_fmode().

◆ FMODE_PREP

#define FMODE_PREP   (1<<16)

Definition at line 4184 of file io.c.

◆ FOREACH_ARGF

#define FOREACH_ARGF ( )    while (next_argv())

Definition at line 11912 of file io.c.

◆ free

#define free (   x)    xfree(x)

Definition at line 25 of file io.c.

◆ GetWriteIO

#define GetWriteIO (   io)    rb_io_get_write_io(io)

Definition at line 407 of file io.c.

◆ id_exception

#define id_exception   idException

Definition at line 166 of file io.c.

◆ IO_CBUF_CAPA_MIN

#define IO_CBUF_CAPA_MIN   (128*1024)

Definition at line 131 of file io.c.

◆ IO_RBUF_CAPA_FOR

#define IO_RBUF_CAPA_FOR (   fptr)    (NEED_READCONV(fptr) ? IO_CBUF_CAPA_MIN : IO_RBUF_CAPA_MIN)

Definition at line 132 of file io.c.

◆ IO_RBUF_CAPA_MIN

#define IO_RBUF_CAPA_MIN   8192

Definition at line 130 of file io.c.

◆ io_seek

#define io_seek (   fptr,
  ofs,
  whence 
)    (errno = 0, lseek(flush_before_seek(fptr)->fd, (ofs), (whence)))

Definition at line 786 of file io.c.

◆ io_tell

#define io_tell (   fptr)    lseek(flush_before_seek(fptr)->fd, 0, SEEK_CUR)

Definition at line 787 of file io.c.

◆ IO_WBUF_CAPA_MIN

#define IO_WBUF_CAPA_MIN   8192

Definition at line 133 of file io.c.

◆ IOWAIT_SYSCALL

#define IOWAIT_SYSCALL   "select"

Definition at line 10419 of file io.c.

◆ IS_PREP_STDIO

#define IS_PREP_STDIO (   f)    ((f)->mode & FMODE_PREP)

Definition at line 4185 of file io.c.

◆ is_socket

#define is_socket (   fd,
  path 
)    0

◆ KEEPGVL

#define KEEPGVL   FALSE

Definition at line 4454 of file io.c.

◆ MAX_REALLOC_GAP

#define MAX_REALLOC_GAP   4096

Definition at line 2387 of file io.c.

◆ MODE_BINARY

#define MODE_BINARY (   a,
 
)    (a)

◆ MODE_BTMODE

#define MODE_BTMODE (   a,
  b,
 
)
Value:
((fmode & FMODE_BINMODE) ? (b) : \
(fmode & FMODE_TEXTMODE) ? (c) : (a))
#define FMODE_BINMODE
Definition: io.h:105
#define fmode
#define FMODE_TEXTMODE
Definition: io.h:113

Definition at line 1365 of file io.c.

◆ MORE_CHAR_FINISHED

#define MORE_CHAR_FINISHED   Qnil

Definition at line 2252 of file io.c.

◆ MORE_CHAR_SUSPENDED

#define MORE_CHAR_SUSPENDED   Qtrue

Definition at line 2251 of file io.c.

◆ NEED_NEWLINE_DECORATOR_ON_READ

#define NEED_NEWLINE_DECORATOR_ON_READ (   fptr)    ((fptr)->mode & FMODE_TEXTMODE)

Definition at line 449 of file io.c.

Referenced by rb_io_eof().

◆ NEED_NEWLINE_DECORATOR_ON_READ_CHECK

#define NEED_NEWLINE_DECORATOR_ON_READ_CHECK (   fptr)    (void)(fptr)

Definition at line 593 of file io.c.

◆ NEED_NEWLINE_DECORATOR_ON_WRITE

#define NEED_NEWLINE_DECORATOR_ON_WRITE (   fptr)    ((fptr)->mode & FMODE_TEXTMODE)

Definition at line 450 of file io.c.

◆ NEED_READCONV

#define NEED_READCONV (   fptr)    ((fptr)->encs.enc2 != NULL || NEED_NEWLINE_DECORATOR_ON_READ(fptr))

Definition at line 590 of file io.c.

Referenced by rb_io_eof().

◆ NEED_WRITECONV

#define NEED_WRITECONV (   fptr)    (((fptr)->encs.enc != NULL && (fptr)->encs.enc != rb_ascii8bit_encoding()) || NEED_NEWLINE_DECORATOR_ON_WRITE(fptr) || ((fptr)->encs.ecflags & (ECONV_DECORATOR_MASK|ECONV_STATEFUL_DECORATOR_MASK)))

Definition at line 591 of file io.c.

◆ NEXT_ARGF_FORWARD

#define NEXT_ARGF_FORWARD (   argc,
  argv 
)
Value:
do {\
if (!next_argv()) return Qnil;\
} while (0)
#define ARGF_FORWARD(argc, argv)
Definition: io.c:8188
return
Definition: zonetab.h:899
int argc
Definition: ruby.c:187
#define Qnil
Definition: ruby.h:438
#define next_argv()
Definition: io.c:8185
char ** argv
Definition: ruby.c:188

Definition at line 8192 of file io.c.

◆ next_argv

#define next_argv ( )    argf_next_argv(argf)

Definition at line 8185 of file io.c.

◆ NOFILE

#define NOFILE   64

Definition at line 75 of file io.c.

◆ NUM2IOCTLREQ

#define NUM2IOCTLREQ (   num)    NUM2INT(num)

Definition at line 9176 of file io.c.

◆ O_ACCMODE

#define O_ACCMODE   (O_RDONLY | O_WRONLY | O_RDWR)

Definition at line 99 of file io.c.

Referenced by Init_fcntl(), and rb_io_oflags_fmode().

◆ off_t

#define off_t   long

Definition at line 61 of file io.c.

Referenced by Init_sizeof().

◆ PIPE_BUF

#define PIPE_BUF   512 /* is this ok? */

Definition at line 110 of file io.c.

◆ PREP_STDIO_NAME

#define PREP_STDIO_NAME (   f)    (RSTRING_PTR((f)->pathv))

Definition at line 4186 of file io.c.

◆ rb_f_syscall

#define rb_f_syscall   rb_f_notimplement

Definition at line 9717 of file io.c.

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

◆ rb_io_close_on_exec_p

#define rb_io_close_on_exec_p   rb_f_notimplement

Definition at line 4123 of file io.c.

◆ rb_io_fcntl

#define rb_io_fcntl   rb_f_notimplement

Definition at line 9587 of file io.c.

◆ rb_io_fdatasync

#define rb_io_fdatasync   rb_io_fsync

Definition at line 1985 of file io.c.

◆ rb_io_fsync

#define rb_io_fsync   rb_f_notimplement

Definition at line 1933 of file io.c.

◆ rb_io_ioctl

#define rb_io_ioctl   rb_f_notimplement

Definition at line 9493 of file io.c.

◆ rb_io_pread

#define rb_io_pread   rb_f_notimplement

Definition at line 4951 of file io.c.

◆ rb_io_pwrite

#define rb_io_pwrite   rb_f_notimplement

Definition at line 5008 of file io.c.

◆ rb_io_set_close_on_exec

#define rb_io_set_close_on_exec   rb_f_notimplement

Definition at line 4181 of file io.c.

◆ rb_io_sync

#define rb_io_sync   rb_f_notimplement

Definition at line 1934 of file io.c.

◆ READ_CHAR_PENDING

#define READ_CHAR_PENDING (   fptr)    ((fptr)->cbuf.len)

Definition at line 414 of file io.c.

Referenced by rb_io_check_byte_readable(), rb_io_eof(), and rb_io_read_pending().

◆ READ_CHAR_PENDING_COUNT

#define READ_CHAR_PENDING_COUNT (   fptr)    ((fptr)->cbuf.len)

Definition at line 415 of file io.c.

◆ READ_CHAR_PENDING_PTR

#define READ_CHAR_PENDING_PTR (   fptr)    ((fptr)->cbuf.ptr+(fptr)->cbuf.off)

Definition at line 416 of file io.c.

◆ READ_CHECK

#define READ_CHECK (   fptr)
Value:
do {\
if (!READ_DATA_PENDING(fptr)) {\
WAIT_FD_IN_WIN32(fptr);\
rb_io_check_closed(fptr);\
}\
} while(0)
#define READ_DATA_PENDING(fptr)
Definition: io.c:409

Definition at line 425 of file io.c.

Referenced by rb_io_eof(), and rb_io_getbyte().

◆ READ_DATA_BUFFERED

#define READ_DATA_BUFFERED (   fptr)    READ_DATA_PENDING(fptr)

Definition at line 412 of file io.c.

◆ READ_DATA_PENDING

#define READ_DATA_PENDING (   fptr)    ((fptr)->rbuf.len)

Definition at line 409 of file io.c.

Referenced by rb_io_eof(), rb_io_read_check(), and rb_io_read_pending().

◆ READ_DATA_PENDING_COUNT

#define READ_DATA_PENDING_COUNT (   fptr)    ((fptr)->rbuf.len)

Definition at line 410 of file io.c.

◆ READ_DATA_PENDING_PTR

#define READ_DATA_PENDING_PTR (   fptr)    ((fptr)->rbuf.ptr+(fptr)->rbuf.off)

Definition at line 411 of file io.c.

◆ S_ISREG

#define S_ISREG (   m)    (((m) & S_IFMT) == S_IFREG)

Definition at line 917 of file io.c.

◆ SEEK_CUR

#define SEEK_CUR   1

Definition at line 791 of file io.c.

◆ SEEK_END

#define SEEK_END   2

Definition at line 792 of file io.c.

◆ SEEK_SET

#define SEEK_SET   0

Definition at line 790 of file io.c.

Referenced by sdbm_firstkey().

◆ SET_BINARY_MODE

#define SET_BINARY_MODE (   fptr)    (void)(fptr)

Definition at line 592 of file io.c.

◆ SET_BINARY_MODE_WITH_SEEK_CUR

#define SET_BINARY_MODE_WITH_SEEK_CUR (   fptr)    (void)(fptr)

Definition at line 595 of file io.c.

Referenced by rb_io_binmode().

◆ SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2

#define SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2 (   enc2,
  ecflags 
)    ((void)(enc2), (void)(ecflags))

Definition at line 594 of file io.c.

◆ SHUT_RD

#define SHUT_RD   0

◆ SHUT_WR

#define SHUT_WR   1

◆ shutdown

#define shutdown (   a,
 
)    0

Definition at line 599 of file io.c.

Referenced by ruby_shutdown().

◆ USE_POLL

#define USE_POLL   0

Definition at line 10420 of file io.c.

◆ WAIT_FD_IN_WIN32

#define WAIT_FD_IN_WIN32 (   fptr)

Definition at line 422 of file io.c.

Typedef Documentation

◆ convconfig_t

typedef struct rb_io_enc_t convconfig_t

Definition at line 5475 of file io.c.

◆ ioctl_req_t

typedef int ioctl_req_t

Definition at line 9175 of file io.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
bom_prefix_len 

Definition at line 5133 of file io.c.

◆ anonymous enum

anonymous enum
Enumerator
utf_prefix_len 

Definition at line 5134 of file io.c.

Function Documentation

◆ Init_IO()

void Init_IO ( void  )

Definition at line 12652 of file io.c.

References NULL, O_BINARY, rb_define_class(), rb_eEOFError, rb_eIOError, and rb_eStandardError.

◆ rb_cloexec_dup()

int rb_cloexec_dup ( int  oldfd)

Definition at line 283 of file io.c.

References rb_cloexec_fcntl_dupfd().

◆ rb_cloexec_dup2()

int rb_cloexec_dup2 ( int  oldfd,
int  newfd 
)

Definition at line 290 of file io.c.

References dup2(), errno, O_CLOEXEC, and rb_maygvl_fd_fix_cloexec().

◆ rb_cloexec_fcntl_dupfd()

int rb_cloexec_fcntl_dupfd ( int  fd,
int  minfd 
)

Definition at line 362 of file io.c.

References errno, F_DUPFD, F_DUPFD_CLOEXEC, fcntl(), and rb_maygvl_fd_fix_cloexec().

Referenced by rb_cloexec_dup().

◆ rb_cloexec_open()

int rb_cloexec_open ( const char *  pathname,
int  flags,
mode_t  mode 
)

Definition at line 257 of file io.c.

References O_CLOEXEC, and rb_maygvl_fd_fix_cloexec().

Referenced by rb_file_load_ok(), and rb_pipe().

◆ rb_cloexec_pipe()

int rb_cloexec_pipe ( int  fildes[2])

Definition at line 325 of file io.c.

References errno, O_CLOEXEC, and rb_maygvl_fd_fix_cloexec().

Referenced by rb_pipe().

◆ rb_eof_error()

void rb_eof_error ( void  )

Definition at line 620 of file io.c.

References rb_eEOFError, and rb_raise().

◆ rb_execarg_commandline()

char* rb_execarg_commandline ( const struct rb_execarg eargp,
VALUE prog 
)

◆ rb_fd_fix_cloexec()

void rb_fd_fix_cloexec ( int  fd)

Definition at line 233 of file io.c.

References rb_maygvl_fd_fix_cloexec(), and rb_update_max_fd().

◆ rb_fdopen()

FILE* rb_fdopen ( int  fd,
const char *  modestr 
)

Definition at line 5716 of file io.c.

References errno, NULL, rb_gc(), rb_gc_for_fd(), rb_syserr_fail(), and rb_warn().

◆ rb_file_open()

VALUE rb_file_open ( const char *  fname,
const char *  modestr 
)

Definition at line 5917 of file io.c.

◆ rb_file_open_str()

VALUE rb_file_open_str ( VALUE  fname,
const char *  modestr 
)

Definition at line 5910 of file io.c.

References FilePathValue.

◆ rb_gc_for_fd()

int rb_gc_for_fd ( int  err)

Definition at line 878 of file io.c.

References rb_gc().

Referenced by rb_fdopen(), and rb_pipe().

◆ rb_get_argv()

VALUE rb_get_argv ( void  )

Definition at line 12413 of file io.c.

References ARGF.

◆ rb_gets()

VALUE rb_gets ( void  )

Definition at line 8504 of file io.c.

References rb_default_rs, and rb_rs.

◆ rb_io_addstr()

VALUE rb_io_addstr ( VALUE  io,
VALUE  str 
)

Definition at line 1532 of file io.c.

References rb_io_t::fd, fsync, binwrite_arg::ptr, rb_io_write(), and rb_w32_get_osfhandle().

◆ rb_io_ascii8bit_binmode()

VALUE rb_io_ascii8bit_binmode ( VALUE  io)

Definition at line 5058 of file io.c.

References GetOpenFile.

Referenced by rsock_init_sock().

◆ rb_io_binmode()

VALUE rb_io_binmode ( VALUE  io)

◆ rb_io_bufread()

ssize_t rb_io_bufread ( VALUE  io,
void *  buf,
size_t  size 
)

Definition at line 2178 of file io.c.

References bufread_arg::fptr, GetOpenFile, and rb_io_check_readable().

◆ rb_io_bufwrite()

ssize_t rb_io_bufwrite ( VALUE  io,
const void *  buf,
size_t  size 
)

Definition at line 1450 of file io.c.

References binwrite_arg::fptr, GetOpenFile, and rb_io_check_writable().

◆ rb_io_check_byte_readable()

void rb_io_check_byte_readable ( rb_io_t fptr)

◆ rb_io_check_char_readable()

void rb_io_check_char_readable ( rb_io_t fptr)

◆ rb_io_check_closed()

void rb_io_check_closed ( rb_io_t fptr)

Definition at line 641 of file io.c.

References rb_io_t::fd, rb_eIOError, rb_io_check_initialized(), and rb_raise().

Referenced by rb_io_check_char_readable(), and rb_io_check_writable().

◆ rb_io_check_initialized()

void rb_io_check_initialized ( rb_io_t fptr)

Definition at line 633 of file io.c.

References rb_eIOError, and rb_raise().

Referenced by rb_io_check_closed(), and rb_io_synchronized().

◆ rb_io_check_io()

VALUE rb_io_check_io ( VALUE  io)

Definition at line 664 of file io.c.

References rb_check_convert_type_with_id(), and T_FILE.

◆ rb_io_check_readable()

void rb_io_check_readable ( rb_io_t fptr)

Definition at line 824 of file io.c.

References rb_io_check_byte_readable().

Referenced by rb_io_bufread().

◆ rb_io_check_writable()

void rb_io_check_writable ( rb_io_t fptr)

Definition at line 848 of file io.c.

References FMODE_WRITABLE, rb_io_t::mode, rb_eIOError, rb_io_check_closed(), rb_raise(), and rb_io_t::rbuf.

Referenced by rb_io_bufwrite().

◆ rb_io_close()

VALUE rb_io_close ( VALUE  io)

Definition at line 4501 of file io.c.

Referenced by rb_io_make_open_file().

◆ rb_io_eof()

VALUE rb_io_eof ( VALUE  io)

◆ rb_io_extract_encoding_option()

int rb_io_extract_encoding_option ( VALUE  opt,
rb_encoding **  enc_p,
rb_encoding **  enc2_p,
int *  fmode_p 
)

Definition at line 5407 of file io.c.

References NIL_P, NULL, Qnil, Qundef, and rb_hash_lookup2().

◆ rb_io_fdopen()

VALUE rb_io_fdopen ( int  fd,
int  oflags,
const char *  path 
)

Definition at line 7648 of file io.c.

References rb_cFile, and rb_cIO.

◆ rb_io_flush()

VALUE rb_io_flush ( VALUE  io)

Definition at line 1592 of file io.c.

References rb_io_flush_raw().

Referenced by rb_io_getbyte().

◆ rb_io_flush_raw()

VALUE rb_io_flush_raw ( VALUE  io,
int  sync 
)

Definition at line 1553 of file io.c.

References binwrite_arg::fptr, rb_funcall(), RB_TYPE_P, and T_FILE.

Referenced by rb_io_flush().

◆ rb_io_fptr_finalize()

int rb_io_fptr_finalize ( rb_io_t fptr)

Definition at line 4424 of file io.c.

References rb_io_t::fd, rb_io_t::pathv, and Qnil.

Referenced by rb_io_make_open_file().

◆ rb_io_get_io()

VALUE rb_io_get_io ( VALUE  io)

Definition at line 658 of file io.c.

References rb_convert_type_with_id(), and T_FILE.

◆ rb_io_get_write_io()

VALUE rb_io_get_write_io ( VALUE  io)

Definition at line 670 of file io.c.

◆ rb_io_getbyte()

VALUE rb_io_getbyte ( VALUE  io)

◆ rb_io_gets()

VALUE rb_io_gets ( VALUE  io)

Definition at line 3281 of file io.c.

◆ rb_io_gets_internal()

VALUE rb_io_gets_internal ( VALUE  io)

Definition at line 3287 of file io.c.

References GetOpenFile.

◆ rb_io_make_open_file()

rb_io_t* rb_io_make_open_file ( VALUE  obj)

Definition at line 7724 of file io.c.

References Check_Type, rb_io_close(), rb_io_fptr_finalize(), RFILE, and T_FILE.

◆ rb_io_memsize()

RUBY_FUNC_EXPORTED size_t rb_io_memsize ( const rb_io_t fptr)

◆ rb_io_modestr_fmode()

int rb_io_modestr_fmode ( const char *  modestr)

◆ rb_io_modestr_oflags()

int rb_io_modestr_oflags ( const char *  modestr)

Definition at line 5262 of file io.c.

◆ rb_io_oflags_fmode()

int rb_io_oflags_fmode ( int  oflags)

◆ rb_io_print()

VALUE rb_io_print ( int  argc,
const VALUE argv,
VALUE  out 
)

Definition at line 7227 of file io.c.

References argc, NIL_P, Qnil, rb_io_write(), rb_lastline_get(), rb_output_fs, and rb_output_rs.

◆ rb_io_printf()

VALUE rb_io_printf ( int  argc,
const VALUE argv,
VALUE  out 
)

Definition at line 7166 of file io.c.

References Qnil, rb_f_sprintf(), and rb_io_write().

◆ rb_io_puts()

VALUE rb_io_puts ( int  argc,
const VALUE argv,
VALUE  out 
)

Definition at line 7399 of file io.c.

References argc, Qnil, rb_default_rs, rb_exec_recursive(), rb_io_write(), RB_TYPE_P, and T_STRING.

Referenced by rb_f_abort().

◆ rb_io_read_check()

void rb_io_read_check ( rb_io_t fptr)

Definition at line 869 of file io.c.

References rb_io_t::fd, rb_thread_wait_fd(), and READ_DATA_PENDING.

◆ rb_io_read_pending()

int rb_io_read_pending ( rb_io_t fptr)

Definition at line 860 of file io.c.

References READ_CHAR_PENDING, and READ_DATA_PENDING.

◆ rb_io_set_nonblock()

void rb_io_set_nonblock ( rb_io_t fptr)

◆ rb_io_set_write_io()

VALUE rb_io_set_write_io ( VALUE  io,
VALUE  w 
)

Definition at line 681 of file io.c.

◆ rb_io_stdio_file()

FILE* rb_io_stdio_file ( rb_io_t fptr)

Definition at line 7676 of file io.c.

References rb_io_t::stdio_file.

◆ rb_io_synchronized()

void rb_io_synchronized ( rb_io_t fptr)

Definition at line 5996 of file io.c.

References FMODE_SYNC, rb_io_t::mode, and rb_io_check_initialized().

Referenced by rb_io_unbuffered(), and rsock_init_sock().

◆ rb_io_taint_check()

VALUE rb_io_taint_check ( VALUE  io)

Definition at line 626 of file io.c.

References rb_check_frozen.

◆ rb_io_unbuffered()

void rb_io_unbuffered ( rb_io_t fptr)

Definition at line 6003 of file io.c.

References rb_io_synchronized().

◆ rb_io_ungetbyte()

VALUE rb_io_ungetbyte ( VALUE  io,
VALUE  b 
)

◆ rb_io_ungetc()

VALUE rb_io_ungetc ( VALUE  io,
VALUE  c 
)

Definition at line 4017 of file io.c.

References FIX2UINT, FIXNUM_P, GetOpenFile, len, NIL_P, Qnil, rb_enc_uint_chr(), and rb_io_check_char_readable().

◆ rb_io_wait_readable()

int rb_io_wait_readable ( int  f)

Definition at line 1106 of file io.c.

References rb_eIOError, and rb_raise().

◆ rb_io_wait_writable()

int rb_io_wait_writable ( int  f)

Definition at line 1132 of file io.c.

References rb_eIOError, and rb_raise().

Referenced by rsock_bsock_send().

◆ rb_io_write()

VALUE rb_io_write ( VALUE  io,
VALUE  str 
)

Definition at line 1510 of file io.c.

References rb_funcallv.

Referenced by rb_io_addstr(), rb_io_print(), rb_io_printf(), rb_io_puts(), and rb_parser_printf().

◆ rb_maygvl_fd_fix_cloexec()

void rb_maygvl_fd_fix_cloexec ( int  fd)

◆ rb_notify_fd_close()

int rb_notify_fd_close ( int  fd)

◆ rb_p()

void rb_p ( VALUE  obj)

◆ rb_pipe()

int rb_pipe ( int *  pipes)

◆ rb_readwrite_sys_fail()

void rb_readwrite_sys_fail ( enum rb_io_wait_readwrite  writable,
const char *  mesg 
)

Definition at line 12447 of file io.c.

◆ rb_readwrite_syserr_fail()

void rb_readwrite_syserr_fail ( enum rb_io_wait_readwrite  writable,
int  n,
const char *  mesg 
)

Definition at line 12453 of file io.c.

◆ rb_stderr_tty_p()

int rb_stderr_tty_p ( void  )

Definition at line 7602 of file io.c.

References rb_stderr.

Referenced by rb_threadptr_error_print().

◆ rb_stdio_set_default_encoding()

void rb_stdio_set_default_encoding ( void  )

Definition at line 11284 of file io.c.

References Qnil.

◆ rb_update_max_fd()

void rb_update_max_fd ( int  fd)

Definition at line 191 of file io.c.

References stat.

Referenced by rb_fd_fix_cloexec(), rb_file_load_ok(), rb_pipe(), and rsock_init_sock().

◆ rb_write_error()

void rb_write_error ( const char *  mesg)

Definition at line 7574 of file io.c.

References rb_write_error2(), and strlen().

◆ rb_write_error2()

void rb_write_error2 ( const char *  mesg,
long  len 
)

Definition at line 7560 of file io.c.

References rb_stderr.

Referenced by rb_write_error().

◆ rb_write_error_str()

void rb_write_error_str ( VALUE  mesg)

Definition at line 7580 of file io.c.

References rb_stderr.

◆ ruby_get_inplace_mode()

const char* ruby_get_inplace_mode ( void  )

Definition at line 12375 of file io.c.

References ARGF, and RSTRING_PTR.

◆ ruby_set_inplace_mode()

void ruby_set_inplace_mode ( const char *  suffix)

Definition at line 12381 of file io.c.

References ARGF, Qfalse, Qnil, and rb_fstring_cstr().

Variable Documentation

◆ rb_cIO

VALUE rb_cIO

Definition at line 143 of file io.c.

Referenced by rb_io_fdopen().

◆ rb_default_rs

VALUE rb_default_rs

Definition at line 162 of file io.c.

Referenced by rb_gets(), and rb_io_puts().

◆ rb_eEOFError

VALUE rb_eEOFError

Definition at line 144 of file io.c.

Referenced by Init_IO(), and rb_eof_error().

◆ rb_eIOError

VALUE rb_eIOError

◆ rb_mWaitReadable

VALUE rb_mWaitReadable

Definition at line 146 of file io.c.

◆ rb_mWaitWritable

VALUE rb_mWaitWritable

Definition at line 147 of file io.c.

◆ rb_output_fs

VALUE rb_output_fs

Definition at line 159 of file io.c.

Referenced by rb_ary_resurrect(), and rb_io_print().

◆ rb_output_rs

VALUE rb_output_rs

Definition at line 161 of file io.c.

Referenced by rb_io_print().

◆ rb_rs

VALUE rb_rs

Definition at line 160 of file io.c.

Referenced by rb_gets().

◆ rb_stderr

VALUE rb_stderr

Definition at line 156 of file io.c.

Referenced by rb_stderr_tty_p(), rb_write_error2(), and rb_write_error_str().

◆ rb_stdin

VALUE rb_stdin

Definition at line 156 of file io.c.

◆ rb_stdout

VALUE rb_stdout

Definition at line 156 of file io.c.

Referenced by rb_io_getbyte(), and rb_p().