Ruby
2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)
|
#include "ruby/encoding.h"
#include "ruby/io.h"
#include "ruby/thread.h"
#include "internal.h"
#include "dln.h"
#include "encindex.h"
#include "id.h"
#include <ctype.h>
#include <errno.h>
#include "ruby_atomic.h"
#include "ccan/list/list.h"
#include "vm_core.h"
#include "builtin.h"
#include <sys/types.h>
#include <sys/stat.h>
#include "ruby/util.h"
#include "io.rbinc"
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 | 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 |
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 } |
#define fmode (fptr->mode) |
#define GetWriteIO | ( | io | ) | rb_io_get_write_io(io) |
#define IO_RBUF_CAPA_FOR | ( | fptr | ) | (NEED_READCONV(fptr) ? IO_CBUF_CAPA_MIN : IO_RBUF_CAPA_MIN) |
#define IS_PREP_STDIO | ( | f | ) | ((f)->mode & FMODE_PREP) |
#define MODE_BINARY | ( | a, | |
b | |||
) | (a) |
#define MODE_BTMODE | ( | a, | |
b, | |||
c | |||
) |
#define MODE_BTXMODE | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f | |||
) |
#define NEED_NEWLINE_DECORATOR_ON_READ | ( | fptr | ) | ((fptr)->mode & FMODE_TEXTMODE) |
#define NEED_NEWLINE_DECORATOR_ON_READ_CHECK | ( | fptr | ) | (void)(fptr) |
#define NEED_NEWLINE_DECORATOR_ON_WRITE | ( | fptr | ) | ((fptr)->mode & FMODE_TEXTMODE) |
#define NEED_READCONV | ( | fptr | ) | ((fptr)->encs.enc2 != NULL || NEED_NEWLINE_DECORATOR_ON_READ(fptr)) |
#define NEED_WRITECONV | ( | fptr | ) |
#define no_exception_p | ( | opts | ) | !rb_opts_exception_p((opts), TRUE) |
#define PREP_STDIO_NAME | ( | f | ) | (RSTRING_PTR((f)->pathv)) |
#define rb_f_syscall rb_f_notimplement |
#define rb_intern | ( | str | ) | rb_intern_const(str) |
#define rb_io_close_on_exec_p rb_f_notimplement |
#define rb_io_fcntl rb_f_notimplement |
#define rb_io_fdatasync rb_io_fsync |
#define rb_io_fptr_finalize | ( | fptr | ) | rb_io_fptr_finalize_internal(fptr) |
#define rb_io_fsync rb_f_notimplement |
#define rb_io_ioctl rb_f_notimplement |
#define rb_io_pread rb_f_notimplement |
#define rb_io_pwrite rb_f_notimplement |
#define rb_io_set_close_on_exec rb_f_notimplement |
#define rb_io_sync rb_f_notimplement |
#define READ_CHAR_PENDING_PTR | ( | fptr | ) | ((fptr)->cbuf.ptr+(fptr)->cbuf.off) |
#define READ_CHECK | ( | fptr | ) |
#define READ_DATA_BUFFERED | ( | fptr | ) | READ_DATA_PENDING(fptr) |
#define READ_DATA_PENDING_PTR | ( | fptr | ) | ((fptr)->rbuf.ptr+(fptr)->rbuf.off) |
#define SHUT_RD 0 |
#define SHUT_WR 1 |
typedef struct rb_io_enc_t convconfig_t |
typedef int ioctl_req_t |
Definition at line 13140 of file io.c.
References NULL, O_BINARY, rb_define_class(), rb_eEOFError, rb_eIOError, and rb_eStandardError.
Definition at line 318 of file io.c.
References rb_cloexec_fcntl_dupfd().
Definition at line 419 of file io.c.
References close(), dup(), EINVAL, errno, F_DUPFD, F_DUPFD_CLOEXEC, fcntl(), rb_cloexec_fcntl_dupfd(), and rb_maygvl_fd_fix_cloexec().
Referenced by rb_cloexec_dup(), and rb_cloexec_fcntl_dupfd().
Definition at line 292 of file io.c.
References O_CLOEXEC, and rb_maygvl_fd_fix_cloexec().
Referenced by rb_file_load_ok().
Definition at line 697 of file io.c.
References rb_eEOFError, and rb_raise().
char* rb_execarg_commandline | ( | const struct rb_execarg * | eargp, |
VALUE * | prog | ||
) |
Definition at line 4317 of file process.c.
References argc, argv, ARGVSTR2ARGV, buf, rb_execarg::cmd, i, rb_execarg::invoke, str, and rb_execarg::use_shell.
Definition at line 268 of file io.c.
References rb_maygvl_fd_fix_cloexec(), and rb_update_max_fd().
Definition at line 6252 of file io.c.
References FilePathValue, and sysopen_struct::fname.
Definition at line 1843 of file io.c.
References rb_io_write(), and str.
Definition at line 5334 of file io.c.
References ECONV_NEWLINE_DECORATOR_MASK, rb_io_t::fd, FMODE_BINMODE, FMODE_TEXTMODE, GetOpenFile, rb_io_t::mode, O_BINARY, rb_econv_binmode(), rb_io_t::readconv, SET_BINARY_MODE_WITH_SEEK_CUR, rb_io_t::writeconv, and rb_io_t::writeconv_pre_ecflags.
Definition at line 1549 of file io.c.
References binwrite_arg::fptr, GetOpenFile, and rb_io_check_writable().
Definition at line 890 of file io.c.
References rb_eIOError, rb_io_check_char_readable(), rb_raise(), and READ_CHAR_PENDING.
Referenced by rb_io_check_readable(), rb_io_getbyte(), and rb_io_ungetbyte().
Definition at line 871 of file io.c.
References FMODE_READABLE, rb_io_t::mode, rb_eIOError, rb_io_check_closed(), rb_raise(), and rb_io_t::wbuf.
Referenced by rb_io_check_byte_readable(), rb_io_eof(), and rb_io_ungetc().
Definition at line 718 of file io.c.
References rb_io_check_initialized().
Referenced by rb_io_check_char_readable(), and rb_io_check_writable().
Definition at line 710 of file io.c.
References rb_eIOError, and rb_raise().
Referenced by rb_io_check_closed(), and rb_io_synchronized().
Definition at line 739 of file io.c.
References idTo_io, rb_check_convert_type_with_id(), and T_FILE.
Definition at line 899 of file io.c.
References rb_io_check_byte_readable().
Definition at line 923 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().
Definition at line 4820 of file io.c.
Referenced by rb_io_make_open_file().
Definition at line 2149 of file io.c.
References rb_io_t::fd, GetOpenFile, NEED_NEWLINE_DECORATOR_ON_READ, NEED_READCONV, Qfalse, Qtrue, rb_io_check_char_readable(), READ_CHAR_PENDING, READ_CHECK, and READ_DATA_PENDING.
int rb_io_extract_encoding_option | ( | VALUE | opt, |
rb_encoding ** | enc_p, | ||
rb_encoding ** | enc2_p, | ||
int * | fmode_p | ||
) |
Definition at line 5744 of file io.c.
References NIL_P, NULL, Qnil, Qundef, rb_encoding, rb_hash_lookup2(), and v.
void rb_io_extract_modeenc | ( | VALUE * | vmode_p, |
VALUE * | vperm_p, | ||
VALUE | opthash, | ||
int * | oflags_p, | ||
int * | fmode_p, | ||
convconfig_t * | convconfig_p | ||
) |
Definition at line 5871 of file io.c.
References fmode, and rb_encoding.
Definition at line 1864 of file io.c.
References rb_funcall, RB_TYPE_P, and T_FILE.
Referenced by rb_io_flush().
Definition at line 4747 of file io.c.
References finish_writeconv_arg::fptr, and rb_io_fptr_finalize_internal().
Definition at line 4730 of file io.c.
References rb_io_t::fd, finish_writeconv_arg::fptr, rb_io_t::pathv, ptr, and Qnil.
Referenced by rb_io_fptr_finalize().
Definition at line 733 of file io.c.
References idTo_io, rb_convert_type_with_id(), and T_FILE.
Definition at line 4215 of file io.c.
References rb_io_t::fd, FMODE_TTY, GetOpenFile, getline_arg::io, rb_io_t::mode, rb_io_check_byte_readable(), rb_io_flush(), rb_stdout, RB_TYPE_P, READ_CHECK, and T_FILE.
Definition at line 3579 of file io.c.
References GetOpenFile, and getline_arg::io.
Definition at line 8080 of file io.c.
References Check_Type, obj, rb_io_close(), rb_io_fptr_finalize, RFILE, and T_FILE.
RUBY_FUNC_EXPORTED size_t rb_io_memsize | ( | const rb_io_t * | fptr | ) |
Definition at line 4760 of file io.c.
References rb_io_t::cbuf, finish_writeconv_arg::fptr, rb_econv_memsize(), rb_io_t::rbuf, rb_io_t::readconv, size, rb_io_t::wbuf, and rb_io_t::writeconv.
Definition at line 5465 of file io.c.
References error, fmode, FMODE_APPEND, FMODE_BINMODE, FMODE_CREATE, FMODE_EXCL, FMODE_READABLE, FMODE_READWRITE, FMODE_TEXTMODE, FMODE_TRUNC, FMODE_WRITABLE, NULL, rb_eArgError, rb_raise(), and strchr().
Definition at line 5519 of file io.c.
References fmode, FMODE_APPEND, FMODE_BINMODE, FMODE_CREATE, FMODE_EXCL, FMODE_READABLE, FMODE_READWRITE, FMODE_TRUNC, FMODE_WRITABLE, O_ACCMODE, and O_BINARY.
Definition at line 7576 of file io.c.
References argc, argv, i, NIL_P, Qnil, rb_io_write(), rb_lastline_get(), rb_output_fs, and rb_output_rs.
Definition at line 7505 of file io.c.
References argc, argv, Qnil, rb_f_sprintf(), and rb_io_write().
Definition at line 7747 of file io.c.
References argc, argv, i, n, Qnil, rb_default_rs, rb_exec_recursive(), rb_io_write(), RB_TYPE_P, and T_STRING.
Referenced by rb_f_abort().
Definition at line 944 of file io.c.
References rb_io_t::fd, rb_thread_wait_fd(), and READ_DATA_PENDING.
Definition at line 935 of file io.c.
References READ_CHAR_PENDING, and READ_DATA_PENDING.
Definition at line 2782 of file io.c.
Referenced by rsock_s_accept_nonblock().
Definition at line 8032 of file io.c.
References rb_io_t::stdio_file.
Definition at line 6356 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().
Definition at line 703 of file io.c.
References rb_check_frozen.
Definition at line 6363 of file io.c.
References rb_io_synchronized().
Definition at line 4276 of file io.c.
References GetOpenFile, INT2FIX, getline_arg::io, NUM2INT, Qnil, rb_int_modulo(), rb_io_check_byte_readable(), rb_str_new, SafeStringValue, T_BIGNUM, T_FIXNUM, T_NIL, TYPE, and v.
Definition at line 4315 of file io.c.
References FIX2UINT, FIXNUM_P, GetOpenFile, getline_arg::io, len, NIL_P, Qnil, rb_enc_uint_chr(), and rb_io_check_char_readable().
Definition at line 1228 of file io.c.
Referenced by rsock_bsock_send().
Definition at line 1804 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().
Definition at line 245 of file io.c.
References errno, F_GETFD, F_SETFD, fcntl(), FD_CLOEXEC, rb_bug(), and strerror().
Referenced by rb_cloexec_dup2(), rb_cloexec_fcntl_dupfd(), rb_cloexec_open(), rb_cloexec_pipe(), and rb_fd_fix_cloexec().
Definition at line 2364 of file thread.c.
References err, waiting_fd::fd, GET_THREAD, list_add, list_del, list_empty, list_for_each_safe, rb_threadptr_interrupt(), rb_threadptr_pending_interrupt_enque(), ruby_error_stream_closed, rb_vm_struct::special_exceptions, waiting_fd::th, rb_thread_struct::vm, rb_vm_struct::waiting_fds, and waiting_fd::wfd_node.
Definition at line 6369 of file io.c.
References errno, rb_cloexec_pipe(), rb_gc_for_fd(), and rb_update_max_fd().
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 | ||
) |
Definition at line 7958 of file io.c.
Referenced by rb_error_write().
Definition at line 218 of file io.c.
Referenced by rb_fd_fix_cloexec(), rb_file_load_ok(), rb_pipe(), and rsock_init_sock().
Definition at line 7930 of file io.c.
References rb_write_error2(), and strlen().
Definition at line 7911 of file io.c.
Referenced by rb_write_error().
VALUE rb_default_rs |
Definition at line 190 of file io.c.
Referenced by rb_gets(), rb_io_puts(), and rb_p().
VALUE rb_output_fs |
Definition at line 187 of file io.c.
Referenced by rb_io_print().
VALUE rb_output_rs |
Definition at line 189 of file io.c.
Referenced by rb_io_print().
VALUE rb_stdout |
Definition at line 184 of file io.c.
Referenced by rb_io_getbyte(), and rb_p().