ext/io/console/console.c File Reference

#include "ruby.h"
#include "ruby/io.h"

Go to the source code of this file.

Data Structures

struct  rawmode_arg_t

Defines

#define SET_LAST_ERROR   (0)
#define GetReadFD(fptr)   ((fptr)->fd)
#define GetWriteFD(fptr)   get_write_fd(fptr)
#define FD_PER_IO   2
#define CONSOLE_DEVICE_FOR_READING   CONSOLE_DEVICE

Functions

static rawmode_arg_trawmode_opt (int argc, VALUE *argv, rawmode_arg_t *opts)
static void set_rawmode (conmode *t, void *arg)
static void set_cookedmode (conmode *t, void *arg)
static void set_noecho (conmode *t, void *arg)
static void set_echo (conmode *t, void *arg)
static int echo_p (conmode *t)
static int set_ttymode (int fd, conmode *t, void(*setter)(conmode *, void *), void *arg)
static int get_write_fd (const rb_io_t *fptr)
static VALUE ttymode (VALUE io, VALUE(*func)(VALUE), void(*setter)(conmode *, void *), void *arg)
static VALUE console_raw (int argc, VALUE *argv, VALUE io)
static VALUE console_set_raw (int argc, VALUE *argv, VALUE io)
static VALUE console_cooked (VALUE io)
static VALUE console_set_cooked (VALUE io)
static VALUE getc_call (VALUE io)
static VALUE console_getch (int argc, VALUE *argv, VALUE io)
static VALUE console_noecho (VALUE io)
static VALUE console_set_echo (VALUE io, VALUE f)
static VALUE console_echo_p (VALUE io)
static VALUE console_iflush (VALUE io)
static VALUE console_oflush (VALUE io)
static VALUE console_ioflush (VALUE io)
static VALUE console_dev (VALUE klass)
static VALUE io_getch (int argc, VALUE *argv, VALUE io)
void Init_console (void)
void InitVM_console (void)

Variables

static ID id_getc
static ID id_console


Define Documentation

#define CONSOLE_DEVICE_FOR_READING   CONSOLE_DEVICE

Referenced by console_dev().

#define FD_PER_IO   2

Definition at line 256 of file console.c.

Referenced by ttymode().

#define GetReadFD ( fptr   )     ((fptr)->fd)

Definition at line 238 of file console.c.

Referenced by console_dev(), console_echo_p(), console_iflush(), console_ioflush(), console_set_cooked(), console_set_echo(), console_set_raw(), and ttymode().

#define GetWriteFD ( fptr   )     get_write_fd(fptr)

Definition at line 253 of file console.c.

Referenced by console_ioflush(), console_oflush(), and ttymode().

#define SET_LAST_ERROR   (0)

Definition at line 91 of file console.c.


Function Documentation

static VALUE console_cooked ( VALUE  io  )  [static]

Definition at line 373 of file console.c.

References NULL, rb_yield(), set_cookedmode(), and ttymode().

Referenced by InitVM_console().

static VALUE console_dev ( VALUE  klass  )  [static]

Definition at line 680 of file console.c.

References args, CONSOLE_DEVICE_FOR_READING, FMODE_SYNC, GetOpenFile, GetReadFD, ID2SYM, INT2FIX, INT2NUM, rb_io_t::mode, rb_io_t::pathv, Qnil, rb_cFile, rb_cIO, rb_class_new_instance(), rb_cloexec_open(), rb_const_defined(), rb_const_get(), rb_const_set(), rb_io_close(), rb_mod_remove_const(), rb_obj_freeze(), rb_str_new2, RB_TYPE_P, rb_update_max_fd(), RFILE, ruby_strdup(), T_FILE, and rb_io_t::tied_io_for_writing.

Referenced by InitVM_console().

static VALUE console_echo_p ( VALUE  io  )  [static]

Definition at line 479 of file console.c.

References echo_p(), GetOpenFile, GetReadFD, Qfalse, Qtrue, and rb_sys_fail().

Referenced by InitVM_console().

static VALUE console_getch ( int  argc,
VALUE *  argv,
VALUE  io 
) [static]

Definition at line 418 of file console.c.

References getc_call(), rawmode_opt(), set_rawmode(), and ttymode().

Referenced by InitVM_console().

static VALUE console_iflush ( VALUE  io  )  [static]

Definition at line 603 of file console.c.

References GetOpenFile, GetReadFD, and rb_sys_fail().

Referenced by InitVM_console().

static VALUE console_ioflush ( VALUE  io  )  [static]

Definition at line 649 of file console.c.

References GetOpenFile, GetReadFD, GetWriteFD, and rb_sys_fail().

Referenced by InitVM_console().

static VALUE console_noecho ( VALUE  io  )  [static]

Definition at line 437 of file console.c.

References NULL, rb_yield(), set_noecho(), and ttymode().

Referenced by InitVM_console().

static VALUE console_oflush ( VALUE  io  )  [static]

Definition at line 626 of file console.c.

References GetOpenFile, GetWriteFD, and rb_sys_fail().

Referenced by InitVM_console().

static VALUE console_raw ( int  argc,
VALUE *  argv,
VALUE  io 
) [static]

Definition at line 328 of file console.c.

References rawmode_opt(), rb_yield(), set_rawmode(), and ttymode().

Referenced by InitVM_console().

static VALUE console_set_cooked ( VALUE  io  )  [static]

Definition at line 389 of file console.c.

References GetOpenFile, GetReadFD, NULL, rb_sys_fail(), and set_cookedmode().

Referenced by InitVM_console().

static VALUE console_set_echo ( VALUE  io,
VALUE  f 
) [static]

Definition at line 453 of file console.c.

References GetOpenFile, GetReadFD, NULL, rb_sys_fail(), RTEST, set_echo(), and set_noecho().

Referenced by InitVM_console().

static VALUE console_set_raw ( int  argc,
VALUE *  argv,
VALUE  io 
) [static]

Definition at line 345 of file console.c.

References GetOpenFile, GetReadFD, rawmode_opt(), rb_sys_fail(), and set_rawmode().

Referenced by InitVM_console().

static int echo_p ( conmode *  t  )  [static]

Definition at line 214 of file console.c.

Referenced by console_echo_p().

static int get_write_fd ( const rb_io_t fptr  )  [inline, static]

Definition at line 245 of file console.c.

References rb_io_t::fd, GetOpenFile, rb_io_t::tied_io_for_writing, and VALUE.

static VALUE getc_call ( VALUE  io  )  [static]

Definition at line 404 of file console.c.

References rb_funcall2.

Referenced by console_getch().

void Init_console ( void   ) 

Definition at line 770 of file console.c.

References InitVM, and rb_intern.

void InitVM_console ( void   ) 

Definition at line 778 of file console.c.

References console_cooked(), console_dev(), console_echo_p(), console_getch(), console_iflush(), console_ioflush(), console_noecho(), console_oflush(), console_raw(), console_set_cooked(), console_set_echo(), console_set_raw(), io_getch(), rb_cIO, rb_define_method(), rb_define_module_under(), and rb_define_singleton_method().

static VALUE io_getch ( int  argc,
VALUE *  argv,
VALUE  io 
) [static]

Definition at line 761 of file console.c.

References rb_funcall2, and rb_intern.

Referenced by InitVM_console().

static rawmode_arg_t* rawmode_opt ( int  argc,
VALUE *  argv,
rawmode_arg_t opts 
) [static]

Definition at line 106 of file console.c.

References Check_Type, ID2SYM, INT2FIX, NIL_P, NULL, NUM2INT, Qnil, rb_check_hash_type(), rb_funcall3, rb_hash_aref(), rb_intern, rb_scan_args(), T_HASH, VALUE, rawmode_arg_t::vmin, and rawmode_arg_t::vtime.

Referenced by console_getch(), console_raw(), and console_set_raw().

static void set_cookedmode ( conmode *  t,
void *  arg 
) [static]

Definition at line 175 of file console.c.

Referenced by console_cooked(), and console_set_cooked().

static void set_echo ( conmode *  t,
void *  arg 
) [static]

Definition at line 202 of file console.c.

Referenced by console_set_echo().

static void set_noecho ( conmode *  t,
void *  arg 
) [static]

Definition at line 190 of file console.c.

Referenced by console_noecho(), and console_set_echo().

static void set_rawmode ( conmode *  t,
void *  arg 
) [static]

Definition at line 148 of file console.c.

References rawmode_arg_t::vmin, and rawmode_arg_t::vtime.

Referenced by console_getch(), console_raw(), and console_set_raw().

static int set_ttymode ( int  fd,
conmode *  t,
void(*)(conmode *, void *)  setter,
void *  arg 
) [static]

Definition at line 226 of file console.c.

Referenced by ttymode().

static VALUE ttymode ( VALUE  io,
VALUE(*)(VALUE)  func,
void(*)(conmode *, void *)  setter,
void *  arg 
) [static]

Definition at line 259 of file console.c.

References errno, FD_PER_IO, GetOpenFile, GetReadFD, GetWriteFD, Qnil, rb_jump_tag(), rb_protect(), rb_sys_fail(), result, and set_ttymode().

Referenced by console_cooked(), console_getch(), console_noecho(), and console_raw().


Variable Documentation

ID id_console [static]

Definition at line 98 of file console.c.

ID id_getc [static]

Definition at line 98 of file console.c.

Referenced by Init_IO().


Generated on 19 Jul 2016 for Ruby by  doxygen 1.4.7