Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Typedefs | Functions
io.h File Reference
#include <stdio.h>
#include <errno.h>
#include "ruby/encoding.h"
#include "ruby/config.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_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

Definition at line 109 of file io.h.

Referenced by rb_io_modestr_fmode(), and rb_io_oflags_fmode().

◆ FMODE_BINMODE

#define FMODE_BINMODE   0x00000004

Definition at line 105 of file io.h.

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

◆ FMODE_CREATE

#define FMODE_CREATE   0x00000080

Definition at line 110 of file io.h.

Referenced by rb_io_modestr_fmode(), and rb_io_oflags_fmode().

◆ FMODE_DUPLEX

#define FMODE_DUPLEX   0x00000020

Definition at line 108 of file io.h.

Referenced by rsock_init_sock().

◆ FMODE_READABLE

#define FMODE_READABLE   0x00000001

Definition at line 102 of file io.h.

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

◆ FMODE_READWRITE

#define FMODE_READWRITE   (FMODE_READABLE|FMODE_WRITABLE)

Definition at line 104 of file io.h.

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

◆ FMODE_SETENC_BY_BOM

#define FMODE_SETENC_BY_BOM   0x00100000

Definition at line 115 of file io.h.

◆ FMODE_SYNC

#define FMODE_SYNC   0x00000008

Definition at line 106 of file io.h.

Referenced by rb_io_synchronized().

◆ FMODE_TEXTMODE

#define FMODE_TEXTMODE   0x00001000

Definition at line 113 of file io.h.

Referenced by rb_io_binmode(), and rb_io_modestr_fmode().

◆ FMODE_TRUNC

#define FMODE_TRUNC   0x00000800

Definition at line 112 of file io.h.

Referenced by 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 rb_io_getbyte().

◆ FMODE_WRITABLE

#define FMODE_WRITABLE   0x00000002

Definition at line 103 of file io.h.

Referenced by rb_io_check_writable(), rb_io_modestr_fmode(), rb_io_oflags_fmode(), and rb_pipe().

◆ GetOpenFile

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

◆ 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:7724

Definition at line 122 of file io.h.

Referenced by 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

Definition at line 47 of file io.h.

Referenced by rb_wait_for_single_fd().

◆ RB_WAITFD_OUT

#define RB_WAITFD_OUT   0x004

Definition at line 49 of file io.h.

◆ RB_WAITFD_PRI

#define RB_WAITFD_PRI   0x002

Definition at line 48 of file io.h.

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

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

◆ 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 )

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 )

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 )

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 )

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_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_fptr_finalize()

int rb_io_fptr_finalize ( rb_io_t )

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_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_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_read_check()

void rb_io_read_check ( rb_io_t )

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 )

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 )

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  )

Definition at line 626 of file io.c.

References rb_check_frozen.

◆ rb_io_wait_readable()

int rb_io_wait_readable ( int  )

Definition at line 1106 of file io.c.

References rb_eIOError, and rb_raise().

◆ rb_io_wait_writable()

int rb_io_wait_writable ( int  )

Definition at line 1132 of file io.c.

References rb_eIOError, and rb_raise().

Referenced by rsock_bsock_send().

◆ rb_stat_new()

VALUE rb_stat_new ( const struct stat )

Definition at line 435 of file file.c.

◆ rb_wait_for_single_fd()

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