Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Typedefs | Functions
io.h File Reference
`#include <stdio.h>`
`#include "ruby/encoding.h"`
`#include "ruby/config.h"`
`#include <errno.h>`

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_EXCL 0x00000400
#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
typedef struct rb_io_enc_t | rb_io_enc_t

## Functions
RUBY_SYMBOL_EXPORT_BEGIN | PACKED_STRUCT_UNALIGNED (struct rb_io_buffer_t { char *ptr;int off;int len;int capa;})
rb_io_t * | rb_io_make_open_file (VALUE obj)
FILE * | rb_io_stdio_file (rb_io_t *fptr)
FILE * | rb_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)
void | rb_io_extract_modeenc (VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, int *oflags_p, int *fmode_p, rb_io_enc_t *convconfig_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

Definition at line 115 of file io.h.

## ◆ FMODE_BINMODE

#define FMODE_BINMODE 0x00000004

Definition at line 111 of file io.h.

## ◆ FMODE_CREATE

#define FMODE_CREATE 0x00000080

Definition at line 116 of file io.h.

## ◆ FMODE_DUPLEX

#define FMODE_DUPLEX 0x00000020

Definition at line 114 of file io.h.

## ◆ FMODE_EXCL

#define FMODE_EXCL 0x00000400

Definition at line 118 of file io.h.

## ◆ FMODE_READABLE

#define FMODE_READABLE 0x00000001

Definition at line 108 of file io.h.

## ◆ FMODE_READWRITE

#define FMODE_READWRITE (FMODE_READABLE|FMODE_WRITABLE)

Definition at line 110 of file io.h.

## ◆ FMODE_SETENC_BY_BOM

#define FMODE_SETENC_BY_BOM 0x00100000

Definition at line 122 of file io.h.

## ◆ FMODE_SYNC

#define FMODE_SYNC 0x00000008

Definition at line 112 of file io.h.

## ◆ FMODE_TEXTMODE

#define FMODE_TEXTMODE 0x00001000

Definition at line 120 of file io.h.

## ◆ FMODE_TRUNC

#define FMODE_TRUNC 0x00000800

Definition at line 119 of file io.h.

## ◆ FMODE_TTY

#define FMODE_TTY 0x00000010

Definition at line 113 of file io.h.

## ◆ FMODE_WRITABLE

#define FMODE_WRITABLE 0x00000002

Definition at line 109 of file io.h.

## ◆ GetOpenFile

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

Definition at line 127 of file io.h.

## ◆ HAVE_RB_IO_T

#define HAVE_RB_IO_T 1

Definition at line 106 of file io.h.

## ◆ MakeOpenFile

#define MakeOpenFile | ( |  | obj,
|  |  | fp
| ) |  |

Value:
do {\
(fp) = rb_io_make_open_file(obj);\
} while (0)

Definition at line 129 of file io.h.

## ◆ rb_io_mode_flags

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

Definition at line 162 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 163 of file io.h.

## ◆ RB_WAITFD_IN

#define RB_WAITFD_IN 0x001

Definition at line 51 of file io.h.

## ◆ RB_WAITFD_OUT

#define RB_WAITFD_OUT 0x004

Definition at line 53 of file io.h.

## ◆ RB_WAITFD_PRI

#define RB_WAITFD_PRI 0x002

Definition at line 52 of file io.h.

## Typedef Documentation

## ◆ rb_io_buffer_t

typedef struct rb_io_buffer_t rb_io_buffer_t

Definition at line 64 of file io.h.

## ◆ rb_io_enc_t

typedef struct rb_io_enc_t rb_io_enc_t

Definition at line 104 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 6053 of file io.c.

References _IOFBF, EINVAL, EMFILE, errno, fdopen(), NULL, rb_gc(), rb_gc_for_fd(), rb_syserr_fail(), rb_warn(), and setvbuf().

## ◆ rb_io_bufwrite()

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

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

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().

## ◆ rb_io_check_char_readable()

void rb_io_check_char_readable | ( | rb_io_t * | fptr | ) |

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().

## ◆ rb_io_check_closed()

void rb_io_check_closed | ( | rb_io_t * |  | ) |

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().

## ◆ rb_io_check_initialized()

void rb_io_check_initialized | ( | rb_io_t * |  | ) |

Definition at line 710 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 739 of file io.c.

References idTo_io, rb_check_convert_type_with_id(), and T_FILE.

## ◆ rb_io_check_readable()

void rb_io_check_readable | ( | rb_io_t * |  | ) |

Definition at line 899 of file io.c.

References rb_io_check_byte_readable().

## ◆ rb_io_check_writable()

void rb_io_check_writable | ( | rb_io_t * |  | ) |

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().

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

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

## ◆ rb_io_extract_modeenc()

void rb_io_extract_modeenc | ( | VALUE * | vmode_p,
|  | VALUE * | vperm_p,
|  | VALUE | opthash,
|  | int * | oflags_p,
|  | int * | fmode_p,
|  | rb_io_enc_t * | convconfig_p
| ) |  |

Definition at line 5871 of file io.c.

References fmode, and rb_encoding.

## ◆ rb_io_fptr_finalize()

int rb_io_fptr_finalize | ( | rb_io_t * |  | ) |

Definition at line 4747 of file io.c.

References finish_writeconv_arg::fptr, and rb_io_fptr_finalize_internal().

## ◆ rb_io_get_io()

VALUE rb_io_get_io | ( | VALUE | io | ) |

Definition at line 733 of file io.c.

## ◆ rb_io_get_write_io()

VALUE rb_io_get_write_io | ( | VALUE | io | ) |

Definition at line 745 of file io.c.

## ◆ rb_io_make_open_file()

rb_io_t* rb_io_make_open_file | ( | VALUE | obj | ) |

Definition at line 8080 of file io.c.

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

## ◆ rb_io_modestr_fmode()

int rb_io_modestr_fmode | ( | const char * | modestr | ) |

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().

## ◆ rb_io_modestr_oflags()

int rb_io_modestr_oflags | ( | const char * | modestr | ) |

Definition at line 5595 of file io.c.

## ◆ rb_io_read_check()

void rb_io_read_check | ( | rb_io_t * |  | ) |

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

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

Definition at line 2782 of file io.c.

Referenced by rsock_s_accept_nonblock().

## ◆ rb_io_set_write_io()

VALUE rb_io_set_write_io | ( | VALUE | io,
|  | VALUE | w
| ) |  |

Definition at line 756 of file io.c.

## ◆ rb_io_stdio_file()

FILE* rb_io_stdio_file | ( | rb_io_t * | fptr | ) |

Definition at line 8032 of file io.c.

References rb_io_t::stdio_file.

## ◆ rb_io_synchronized()

void rb_io_synchronized | ( | rb_io_t * |  | ) |

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().

## ◆ rb_io_taint_check()

VALUE rb_io_taint_check | ( | VALUE |  | ) |

Definition at line 703 of file io.c.

References rb_check_frozen.

## ◆ rb_io_wait_readable()

int rb_io_wait_readable | ( | int |  | ) |

Definition at line 1204 of file io.c.

## ◆ rb_io_wait_writable()

int rb_io_wait_writable | ( | int |  | ) |

Definition at line 1228 of file io.c.

Referenced by rsock_bsock_send().

## ◆ rb_stat_new()

VALUE rb_stat_new | ( | const struct stat * |  | ) |

Definition at line 492 of file file.c.

## ◆ rb_wait_for_single_fd()

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

Definition at line 4276 of file thread.c.

References select_args::as, select_args::fd, ptr, RB_WAITFD_IN, and select_args::read.

rb_io_make_open_file
rb_io_t * rb_io_make_open_file(VALUE obj)
Definition: io.c:8080
obj
const VALUE VALUE obj
Definition: rb_mjit_min_header-2.7.0.h:5742