Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Typedefs | Functions
io.h File Reference
#include <stdio.h>
#include <errno.h>
#include "ruby/encoding.h"
#include "ruby/config.h"
Include dependency graph for io.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rb_io_t
 
struct  rb_io_t::rb_io_enc_t
 

Macros

#define RB_WAITFD_IN   0x001
 
#define RB_WAITFD_PRI   0x002
 
#define RB_WAITFD_OUT   0x004
 
#define HAVE_RB_IO_T   1
 
#define FMODE_READABLE   0x00000001
 
#define FMODE_WRITABLE   0x00000002
 
#define FMODE_READWRITE   (FMODE_READABLE|FMODE_WRITABLE)
 
#define FMODE_BINMODE   0x00000004
 
#define FMODE_SYNC   0x00000008
 
#define FMODE_TTY   0x00000010
 
#define FMODE_DUPLEX   0x00000020
 
#define FMODE_APPEND   0x00000040
 
#define FMODE_CREATE   0x00000080
 
#define FMODE_TRUNC   0x00000800
 
#define FMODE_TEXTMODE   0x00001000
 
#define FMODE_SETENC_BY_BOM   0x00100000
 
#define GetOpenFile(obj, fp)   rb_io_check_closed((fp) = RFILE(rb_io_taint_check(obj))->fptr)
 
#define MakeOpenFile(obj, fp)
 
#define rb_io_mode_flags(modestr)   [<"rb_io_mode_flags() is obsolete; use rb_io_modestr_fmode()">]
 
#define rb_io_modenum_flags(oflags)   [<"rb_io_modenum_flags() is obsolete; use rb_io_oflags_fmode()">]
 

Typedefs

typedef struct rb_io_buffer_t rb_io_buffer_t
 
typedef struct rb_io_t rb_io_t
 

Functions

RUBY_SYMBOL_EXPORT_BEGIN PACKED_STRUCT_UNALIGNED (struct rb_io_buffer_t { char *ptr;int off;int len;int capa;})
 
rb_io_trb_io_make_open_file (VALUE obj)
 
FILErb_io_stdio_file (rb_io_t *fptr)
 
FILErb_fdopen (int, const char *)
 
int rb_io_modestr_fmode (const char *modestr)
 
int rb_io_modestr_oflags (const char *modestr)
 
 CONSTFUNC (int rb_io_oflags_fmode(int oflags))
 
void rb_io_check_writable (rb_io_t *)
 
void rb_io_check_readable (rb_io_t *)
 
void rb_io_check_char_readable (rb_io_t *fptr)
 
void rb_io_check_byte_readable (rb_io_t *fptr)
 
int rb_io_fptr_finalize (rb_io_t *)
 
void rb_io_synchronized (rb_io_t *)
 
void rb_io_check_initialized (rb_io_t *)
 
void rb_io_check_closed (rb_io_t *)
 
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)
 
int rb_io_wait_readable (int)
 
int rb_io_wait_writable (int)
 
int rb_wait_for_single_fd (int fd, int events, struct timeval *tv)
 
void rb_io_set_nonblock (rb_io_t *fptr)
 
int rb_io_extract_encoding_option (VALUE opt, rb_encoding **enc_p, rb_encoding **enc2_p, int *fmode_p)
 
ssize_t rb_io_bufwrite (VALUE io, const void *buf, size_t size)
 
VALUE rb_io_taint_check (VALUE)
 
 NORETURN (void rb_eof_error(void))
 
void rb_io_read_check (rb_io_t *)
 
int rb_io_read_pending (rb_io_t *)
 
VALUE rb_stat_new (const struct stat *)
 

Macro Definition Documentation

◆ FMODE_APPEND

#define FMODE_APPEND   0x00000040

◆ FMODE_BINMODE

#define FMODE_BINMODE   0x00000004

◆ FMODE_CREATE

#define FMODE_CREATE   0x00000080

◆ FMODE_DUPLEX

#define FMODE_DUPLEX   0x00000020

◆ FMODE_READABLE

#define FMODE_READABLE   0x00000001

◆ FMODE_READWRITE

#define FMODE_READWRITE   (FMODE_READABLE|FMODE_WRITABLE)

◆ FMODE_SETENC_BY_BOM

#define FMODE_SETENC_BY_BOM   0x00100000

◆ FMODE_SYNC

#define FMODE_SYNC   0x00000008

◆ FMODE_TEXTMODE

#define FMODE_TEXTMODE   0x00001000

◆ FMODE_TRUNC

#define FMODE_TRUNC   0x00000800

Definition at line 112 of file io.h.

Referenced by rb_io_fmode_oflags(), rb_io_modestr_fmode(), and rb_io_oflags_fmode().

◆ FMODE_TTY

#define FMODE_TTY   0x00000010

Definition at line 107 of file io.h.

Referenced by io_binwrite(), io_check_tty(), io_fwrite(), pty_open(), and rb_io_getbyte().

◆ FMODE_WRITABLE

#define FMODE_WRITABLE   0x00000002

◆ GetOpenFile

#define GetOpenFile (   obj,
  fp 
)    rb_io_check_closed((fp) = RFILE(rb_io_taint_check(obj))->fptr)

Definition at line 120 of file io.h.

Referenced by argf_next_argv(), argf_set_encoding(), bsock_close_read(), bsock_close_write(), bsock_do_not_reverse_lookup(), bsock_do_not_reverse_lookup_set(), bsock_getpeername(), bsock_getsockname(), bsock_getsockopt(), bsock_local_address(), bsock_remote_address(), bsock_s_for_fd(), bsock_setsockopt(), bsock_shutdown(), check_exec_redirect_fd(), check_getline_args(), console_beep(), console_dev(), console_echo_p(), console_iflush(), console_ioflush(), console_oflush(), console_set_cooked(), console_set_echo(), console_set_raw(), copy_stream_body(), dump_output(), get_write_fd(), io_getpartial(), io_nread(), io_read(), io_read_nonblock(), io_ready_p(), io_reopen(), io_set_encoding_by_bom(), io_wait_readable(), io_wait_readwrite(), io_wait_writable(), io_write(), io_write_nonblock(), ip_addr(), ip_peeraddr(), ossl_ssl_read_internal(), ossl_ssl_setup(), ossl_ssl_write_internal(), ossl_start_ssl(), prep_stdio(), rb_f_backquote(), rb_fiddle_ptr_s_to_ptr(), rb_file_atime(), rb_file_chmod(), rb_file_chown(), rb_file_ctime(), rb_file_flock(), rb_file_lstat(), rb_file_mtime(), rb_file_size(), rb_io_advise(), rb_io_ascii8bit_binmode(), rb_io_binmode(), rb_io_binmode_p(), rb_io_bufread(), rb_io_bufwrite(), rb_io_check_char_readable(), rb_io_each_byte(), rb_io_each_char(), rb_io_each_codepoint(), rb_io_eof(), rb_io_external_encoding(), rb_io_flush_raw(), rb_io_getbyte(), rb_io_getc(), rb_io_getline_1(), rb_io_gets_internal(), rb_io_init_copy(), rb_io_internal_encoding(), rb_io_isatty(), rb_io_lineno(), rb_io_pid(), rb_io_rewind(), rb_io_s_pipe(), rb_io_seek(), rb_io_set_autoclose(), rb_io_set_encoding(), rb_io_set_lineno(), rb_io_set_pos(), rb_io_set_sync(), rb_io_stat(), rb_io_sync(), rb_io_sysread(), rb_io_sysseek(), rb_io_syswrite(), rb_io_tell(), rb_io_ungetbyte(), rb_io_ungetc(), rb_stat(), readline_s_set_input(), readline_s_set_output(), rsock_bsock_send(), rsock_io_socket_addrinfo(), rsock_s_recvfrom(), rsock_s_recvfrom_nonblock(), rsock_sock_listen(), select_internal(), setup_narg(), sock_accept(), sock_accept_nonblock(), sock_bind(), sock_connect(), sock_connect_nonblock(), sock_sysaccept(), tcp_accept(), tcp_accept_nonblock(), tcp_sysaccept(), ttymode(), udp_bind(), udp_connect(), and udp_send().

◆ HAVE_RB_IO_T

#define HAVE_RB_IO_T   1

Definition at line 100 of file io.h.

◆ MakeOpenFile

#define MakeOpenFile (   obj,
  fp 
)
Value:
do {\
(fp) = rb_io_make_open_file(obj);\
} while (0)
rb_io_t * rb_io_make_open_file(VALUE obj)
Definition: io.c:7529

Definition at line 122 of file io.h.

Referenced by pipe_open(), prep_io(), pty_getpty(), pty_open(), rb_file_open_generic(), rb_io_init_copy(), rb_io_initialize(), and rsock_init_sock().

◆ rb_io_mode_flags

#define rb_io_mode_flags (   modestr)    [<"rb_io_mode_flags() is obsolete; use rb_io_modestr_fmode()">]

Definition at line 154 of file io.h.

◆ rb_io_modenum_flags

#define rb_io_modenum_flags (   oflags)    [<"rb_io_modenum_flags() is obsolete; use rb_io_oflags_fmode()">]

Definition at line 155 of file io.h.

◆ RB_WAITFD_IN

#define RB_WAITFD_IN   0x001

◆ RB_WAITFD_OUT

#define RB_WAITFD_OUT   0x004

◆ RB_WAITFD_PRI

#define RB_WAITFD_PRI   0x002

Definition at line 48 of file io.h.

Referenced by rb_thread_fd_select(), rb_wait_for_single_fd(), and select_single().

Typedef Documentation

◆ rb_io_buffer_t

Definition at line 60 of file io.h.

◆ rb_io_t

typedef struct rb_io_t rb_io_t

Function Documentation

◆ CONSTFUNC()

CONSTFUNC ( int   rb_io_oflags_fmodeint oflags)

◆ NORETURN()

NORETURN ( void   rb_eof_errorvoid)

◆ PACKED_STRUCT_UNALIGNED()

RUBY_SYMBOL_EXPORT_BEGIN PACKED_STRUCT_UNALIGNED ( struct rb_io_buffer_t { char *ptr;int off;int len;int capa;}  )

◆ rb_fdopen()

FILE* rb_fdopen ( int  ,
const char *   
)

Definition at line 5537 of file io.c.

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

Referenced by rb_io_stdio_file().

◆ rb_io_bufwrite()

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

Definition at line 1448 of file io.c.

References binwrite_arg::fptr, GetOpenFile, io_binwrite(), 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 )

◆ rb_io_check_initialized()

void rb_io_check_initialized ( rb_io_t )

Definition at line 631 of file io.c.

References rb_eIOError, and rb_raise().

Referenced by prepare_readline(), rb_file_path(), rb_io_check_closed(), rb_io_get_fptr(), and rb_io_synchronized().

◆ rb_io_check_io()

VALUE rb_io_check_io ( VALUE  io)

◆ rb_io_check_readable()

void rb_io_check_readable ( rb_io_t )

Definition at line 822 of file io.c.

References rb_io_check_byte_readable().

Referenced by io_nread(), io_ready_p(), io_wait_readable(), ossl_ssl_setup(), and rb_io_bufread().

◆ rb_io_check_writable()

void rb_io_check_writable ( rb_io_t )

◆ rb_io_extract_encoding_option()

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

◆ rb_io_fptr_finalize()

int rb_io_fptr_finalize ( rb_io_t )

◆ rb_io_get_io()

VALUE rb_io_get_io ( VALUE  io)

Definition at line 656 of file io.c.

References rb_convert_type(), and T_FILE.

Referenced by io_reopen(), rb_io_init_copy(), and select_internal().

◆ rb_io_get_write_io()

VALUE rb_io_get_write_io ( VALUE  io)

Definition at line 668 of file io.c.

References rb_io_get_fptr(), and rb_io_t::tied_io_for_writing.

Referenced by dump_output(), and io_getch().

◆ rb_io_make_open_file()

rb_io_t* rb_io_make_open_file ( VALUE  obj)

Definition at line 7529 of file io.c.

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

◆ 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 5086 of file io.c.

References rb_io_fmode_oflags(), and rb_io_modestr_fmode().

Referenced by check_exec_redirect(), and rb_io_s_sysopen().

◆ rb_io_read_check()

void rb_io_read_check ( rb_io_t )

Definition at line 867 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 )

◆ 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 679 of file io.c.

References GetWriteIO, Qnil, rb_io_get_fptr(), RTEST, and rb_io_t::tied_io_for_writing.

Referenced by argf_close(), and argf_next_argv().

◆ rb_io_stdio_file()

FILE* rb_io_stdio_file ( rb_io_t fptr)

◆ rb_io_synchronized()

void rb_io_synchronized ( rb_io_t )

Definition at line 5809 of file io.c.

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

Referenced by pipe_open(), rb_io_s_pipe(), rb_io_unbuffered(), and rsock_init_sock().

◆ rb_io_taint_check()

VALUE rb_io_taint_check ( VALUE  )

◆ rb_io_wait_readable()

int rb_io_wait_readable ( int  )

◆ rb_io_wait_writable()

int rb_io_wait_writable ( int  )

◆ rb_stat_new()

VALUE rb_stat_new ( const struct stat )

Definition at line 416 of file file.c.

References rb_cStat, stat, and stat_new_0().

Referenced by rb_file_lstat(), rb_file_s_lstat(), rb_file_s_stat(), and rb_io_stat().

◆ rb_wait_for_single_fd()

int rb_wait_for_single_fd ( int  fd,
int  events,
struct timeval tv 
)