Ruby  3.4.0dev (2024-11-22 revision 0989400a925cd201defdca9eb28eb87200b30785)
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 
52 
53 /* io.c */ /* ...why? given rb_fs is in string.c? */
54 
63 
76 
85 
94 
117 VALUE rb_io_write(VALUE io, VALUE str);
118 
133 
152 
176 
190 
211 
231 
245 VALUE rb_io_eof(VALUE io);
246 
273 
287 
305 VALUE rb_io_addstr(VALUE io, VALUE str);
306 
325 VALUE rb_io_printf(int argc, const VALUE *argv, VALUE io);
326 
351 VALUE rb_io_print(int argc, const VALUE *argv, VALUE io);
352 
377 VALUE rb_io_puts(int argc, const VALUE *argv, VALUE io);
378 
391 VALUE rb_io_fdopen(int fd, int flags, const char *path);
392 
430 VALUE rb_file_open(const char *fname, const char *fmode);
431 
446 VALUE rb_file_open_str(VALUE fname, const char *fmode);
447 
475 VALUE rb_gets(void);
476 
497 void rb_write_error(const char *str);
498 
507 void rb_write_error2(const char *str, long len);
508 
530 void rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds);
531 
542 int rb_pipe(int *pipes);
543 
553 int rb_reserved_fd_p(int fd);
554 
556 #define RB_RESERVED_FD_P(fd) rb_reserved_fd_p(fd)
557 
577 int rb_cloexec_open(const char *pathname, int flags, mode_t mode);
578 
587 int rb_cloexec_dup(int oldfd);
588 
603 int rb_cloexec_dup2(int oldfd, int newfd);
604 
619 int rb_cloexec_pipe(int fildes[2]);
620 
638 int rb_cloexec_fcntl_dupfd(int fd, int minfd);
639 
646 void rb_update_max_fd(int fd);
647 
657 void 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:45
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:65
VALUE rb_io_printf(int argc, const VALUE *argv, VALUE io)
This is a rb_f_sprintf() + rb_io_write() combo.
Definition: io.c:8566
VALUE rb_io_gets(VALUE io)
Reads a "line" from the given IO.
Definition: io.c:4262
int rb_cloexec_pipe(int fildes[2])
Opens a pipe with closing on exec.
Definition: io.c:427
VALUE rb_rs
The record separator character for inputs, or the $/.
Definition: io.c:205
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:8692
VALUE rb_io_addstr(VALUE io, VALUE str)
Identical to rb_io_write(), except it always returns the passed IO.
Definition: io.c:2344
void rb_write_error(const char *str)
Writes the given error message to somewhere applicable.
Definition: io.c:9121
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:5131
VALUE rb_io_getbyte(VALUE io)
Reads a byte from the given IO.
Definition: io.c:5037
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:8924
int rb_cloexec_dup2(int oldfd, int newfd)
Identical to rb_cloexec_dup(), except you can specify the destination file descriptor.
Definition: io.c:374
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:9297
void rb_update_max_fd(int fd)
Informs the interpreter that the passed fd can be the max.
Definition: io.c:248
VALUE rb_io_write(VALUE io, VALUE str)
Writes the given string to the given IO.
Definition: io.c:2296
int rb_cloexec_open(const char *pathname, int flags, mode_t mode)
Opens a file that closes on exec.
Definition: io.c:328
VALUE rb_fs
The field separator character for inputs, or the $;.
Definition: string.c:669
VALUE rb_output_rs
The record separator character for outputs, or the $\.
Definition: io.c:206
VALUE rb_io_eof(VALUE io)
Queries if the passed IO is at the end of file.
Definition: io.c:2689
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:9101
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:298
VALUE rb_io_flush(VALUE io)
Flushes any buffered data within the passed IO to the underlying operating system.
Definition: io.c:2400
VALUE rb_io_ascii8bit_binmode(VALUE io)
Forces no conversions be applied to the passed IO.
Definition: io.c:6343
VALUE rb_io_binmode(VALUE io)
Sets the binmode.
Definition: io.c:6297
VALUE rb_io_ungetc(VALUE io, VALUE c)
"Unget"s a string.
Definition: io.c:5195
int rb_pipe(int *pipes)
This is an rb_cloexec_pipe() + rb_update_max_fd() combo.
Definition: io.c:7344
VALUE rb_gets(void)
Much like rb_io_gets(), but it reads from the mysterious ARGF object.
Definition: io.c:10366
int rb_cloexec_fcntl_dupfd(int fd, int minfd)
Duplicates a file descriptor with closing on exec.
Definition: io.c:461
VALUE rb_output_fs
The field separator character for outputs, or the $,.
Definition: io.c:204
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:7227
int rb_cloexec_dup(int oldfd)
Identical to rb_cloexec_fcntl_dupfd(), except it implies minfd is 3.
Definition: io.c:367
VALUE rb_file_open(const char *fname, const char *fmode)
Opens a file located at the given path.
Definition: io.c:7234
VALUE rb_io_close(VALUE io)
Closes the IO.
Definition: io.c:5717
VALUE rb_default_rs
This is the default value of rb_rs, i.e.
Definition: io.c:207
int len
Length of the buffer.
Definition: io.h:8
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition: nonnull.h:27
Defines VALUE and ID.
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40