Ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e0ba6b95ab71a441357ed5484e33498)
io.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_IO_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_IO_H
24#include "ruby/internal/value.h"
25
27
28/* io.c */
29
30
37#define rb_defout rb_stdout
38
39/* string.c */ /* ...why? moved in commit de7161526014b781468cea5d84411e23be */
40
51RUBY_EXTERN VALUE rb_fs;
52
53/* io.c */ /* ...why? given rb_fs is in string.c? */
54
63
75RUBY_EXTERN VALUE rb_rs;
76
85
94
117VALUE rb_io_write(VALUE io, VALUE str);
118
132VALUE rb_io_gets(VALUE io);
133
151VALUE rb_io_getbyte(VALUE io);
152
175VALUE rb_io_ungetc(VALUE io, VALUE c);
176
189VALUE rb_io_ungetbyte(VALUE io, VALUE b);
190
210VALUE rb_io_close(VALUE io);
211
230VALUE rb_io_flush(VALUE io);
231
245VALUE rb_io_eof(VALUE io);
246
272VALUE rb_io_binmode(VALUE io);
273
286VALUE rb_io_ascii8bit_binmode(VALUE io);
287
305VALUE rb_io_addstr(VALUE io, VALUE str);
306
325VALUE rb_io_printf(int argc, const VALUE *argv, VALUE io);
326
351VALUE rb_io_print(int argc, const VALUE *argv, VALUE io);
352
377VALUE rb_io_puts(int argc, const VALUE *argv, VALUE io);
378
391VALUE rb_io_fdopen(int fd, int flags, const char *path);
392
430VALUE rb_file_open(const char *fname, const char *fmode);
431
446VALUE rb_file_open_str(VALUE fname, const char *fmode);
447
475VALUE rb_gets(void);
476
497void rb_write_error(const char *str);
498
507void rb_write_error2(const char *str, long len);
508
530void rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds);
531
542int rb_pipe(int *pipes);
543
554
556#define RB_RESERVED_FD_P(fd) rb_reserved_fd_p(fd)
557
577int rb_cloexec_open(const char *pathname, int flags, mode_t mode);
578
587int rb_cloexec_dup(int oldfd);
588
603int rb_cloexec_dup2(int oldfd, int newfd);
604
619int rb_cloexec_pipe(int fildes[2]);
620
638int rb_cloexec_fcntl_dupfd(int fd, int minfd);
639
646void rb_update_max_fd(int fd);
647
657void rb_fd_fix_cloexec(int fd);
658
660
661#endif /* RBIMPL_INTERN_IO_H */
Tweaking visibility of C variables/functions.
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition: dllexport.h:47
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:106
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:97
VALUE rb_io_printf(int argc, const VALUE *argv, VALUE io)
This is a rb_f_sprintf() + rb_io_write() combo.
Definition: io.c:7955
VALUE rb_io_gets(VALUE io)
Reads a "line" from the given IO.
Definition: io.c:3955
int rb_cloexec_pipe(int fildes[2])
Opens a pipe with closing on exec.
Definition: io.c:413
VALUE rb_rs
The record separator character for inputs, or the $/.
Definition: io.c:202
VALUE rb_io_print(int argc, const VALUE *argv, VALUE io)
Iterates over the passed array to apply rb_io_write() individually.
Definition: io.c:8026
VALUE rb_io_addstr(VALUE io, VALUE str)
Identical to rb_io_write(), except it always returns the passed IO.
Definition: io.c:2106
void rb_write_error(const char *str)
Writes the given error message to somewhere applicable.
Definition: io.c:8391
VALUE rb_io_ungetbyte(VALUE io, VALUE b)
Identical to rb_io_ungetc(), except it doesn't take the encoding of the passed IO into account.
Definition: io.c:4668
VALUE rb_io_getbyte(VALUE io)
Reads a byte from the given IO.
Definition: io.c:4587
VALUE rb_io_puts(int argc, const VALUE *argv, VALUE io)
Iterates over the passed array to apply rb_io_write() individually.
Definition: io.c:8208
int rb_cloexec_dup2(int oldfd, int newfd)
Identical to rb_cloexec_dup(), except you can specify the destination file descriptor.
Definition: io.c:360
VALUE rb_io_fdopen(int fd, int flags, const char *path)
Creates an IO instance whose backend is the given file descriptor.
Definition: io.c:8498
void rb_update_max_fd(int fd)
Informs the interpreter that the passed fd can be the max.
Definition: io.c:234
VALUE rb_io_write(VALUE io, VALUE str)
Writes the given string to the given IO.
Definition: io.c:2063
int rb_cloexec_open(const char *pathname, int flags, mode_t mode)
Opens a file that closes on exec.
Definition: io.c:314
VALUE rb_fs
The field separator character for inputs, or the $;.
Definition: string.c:553
VALUE rb_output_rs
The record separator character for outputs, or the $\.
Definition: io.c:203
VALUE rb_io_eof(VALUE io)
Queries if the passed IO is at the end of file.
Definition: io.c:2450
void rb_write_error2(const char *str, long len)
Identical to rb_write_error(), except it additionally takes the message's length.
Definition: io.c:8371
void rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds)
Closes everything.
int rb_reserved_fd_p(int fd)
Queries if the given FD is reserved or not.
void rb_fd_fix_cloexec(int fd)
Sets or clears the close-on-exec flag of the passed file descriptor to the desired state.
Definition: io.c:284
VALUE rb_io_flush(VALUE io)
Flushes any buffered data within the passed IO to the underlying operating system.
Definition: io.c:2162
VALUE rb_io_ascii8bit_binmode(VALUE io)
Forces no conversions be applied to the passed IO.
Definition: io.c:5788
VALUE rb_io_binmode(VALUE io)
Sets the binmode.
Definition: io.c:5742
VALUE rb_io_ungetc(VALUE io, VALUE c)
"Unget"s a string.
Definition: io.c:4723
int rb_pipe(int *pipes)
This is an rb_cloexec_pipe() + rb_update_max_fd() combo.
Definition: io.c:6792
VALUE rb_gets(void)
Much like rb_io_gets(), but it reads from the mysterious ARGF object.
Definition: io.c:9419
int rb_cloexec_fcntl_dupfd(int fd, int minfd)
Duplicates a file descriptor with closing on exec.
Definition: io.c:447
VALUE rb_output_fs
The field separator character for outputs, or the $,.
Definition: io.c:201
VALUE rb_file_open_str(VALUE fname, const char *fmode)
Identical to rb_file_open(), except it takes the pathname as a Ruby's string instead of C's.
Definition: io.c:6675
int rb_cloexec_dup(int oldfd)
Identical to rb_cloexec_fcntl_dupfd(), except it implies minfd is 3.
Definition: io.c:353
VALUE rb_file_open(const char *fname, const char *fmode)
Opens a file located at the given path.
Definition: io.c:6682
VALUE rb_io_close(VALUE io)
Closes the IO.
Definition: io.c:5234
VALUE rb_default_rs
This is the default value of rb_rs, i.e.
Definition: io.c:204
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition: nonnull.h:27
Defines VALUE and ID.