Ruby 3.5.0dev (2025-02-22 revision 412997300569c1853c09813e4924b6df3d7e8669)
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
117VALUE rb_io_write(VALUE io, VALUE str);
118
133
152
176
190
211
230VALUE rb_io_flush(VALUE io);
231
246
273
287
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: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:8601
VALUE rb_io_gets(VALUE io)
Reads a "line" from the given IO.
Definition io.c:4297
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:8727
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:9156
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:5166
VALUE rb_io_getbyte(VALUE io)
Reads a byte from the given IO.
Definition io.c:5072
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:9332
void rb_update_max_fd(int fd)
Informs the interpreter that the passed fd can be the max.
Definition io.c:248
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:670
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:9136
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_ascii8bit_binmode(VALUE io)
Forces no conversions be applied to the passed IO.
Definition io.c:6378
VALUE rb_io_binmode(VALUE io)
Sets the binmode.
Definition io.c:6332
VALUE rb_io_ungetc(VALUE io, VALUE c)
"Unget"s a string.
Definition io.c:5230
int rb_pipe(int *pipes)
This is an rb_cloexec_pipe() + rb_update_max_fd() combo.
Definition io.c:7379
VALUE rb_gets(void)
Much like rb_io_gets(), but it reads from the mysterious ARGF object.
Definition io.c:10401
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:7262
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:7269
VALUE rb_io_close(VALUE io)
Closes the IO.
Definition io.c:5752
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:30
Defines VALUE and ID.
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40