Ruby: include/ruby/internal/intern/io.h Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

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
23#include "ruby/internal/dllexport.h"
24#include "ruby/internal/value.h"
25
26 RBIMPL_SYMBOL_EXPORT_BEGIN()
27
28/* io.c */
29
30
37#define rb_defout rb_stdout
38
39/* string.c */ /* ...why? moved in commit de7161526014b781468cea5d84411e23be */
40
51 RUBY_EXTERN VALUE rb_fs;
52
53/* io.c */ /* ...why? given rb_fs is in string.c? */
54
62 RUBY_EXTERN VALUE rb_output_fs;
63
75 RUBY_EXTERN VALUE rb_rs;
76
84 RUBY_EXTERN VALUE rb_default_rs;
85
93 RUBY_EXTERN VALUE rb_output_rs;
94
117 VALUE rb_io_write(VALUE io, VALUE str);
118
132 VALUE rb_io_gets(VALUE io);
133
151 VALUE rb_io_getbyte(VALUE io);
152
175 VALUE rb_io_ungetc(VALUE io, VALUE c);
176
189 VALUE rb_io_ungetbyte(VALUE io, VALUE b);
190
210 VALUE rb_io_close(VALUE io);
211
230 VALUE rb_io_flush(VALUE io);
231
245 VALUE rb_io_eof(VALUE io);
246
272 VALUE rb_io_binmode(VALUE io);
273
286 VALUE rb_io_ascii8bit_binmode(VALUE io);
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
393 RBIMPL_ATTR_NONNULL(())
430 VALUE rb_file_open(const char *fname, const char *fmode);
431
432 RBIMPL_ATTR_NONNULL(())
446 VALUE rb_file_open_str(VALUE fname, const char *fmode);
447
475 VALUE rb_gets(void);
476
477 RBIMPL_ATTR_NONNULL(())
497void rb_write_error(const char *str);
498
507void rb_write_error2(const char *str, long len);
508
530 void rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds);
531
532 RBIMPL_ATTR_NONNULL(())
542int 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
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
605 RBIMPL_ATTR_NONNULL(())
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
659 RBIMPL_SYMBOL_EXPORT_END()
660
661#endif /* RBIMPL_INTERN_IO_H */
dllexport.h
Tweaking visibility of C variables/functions.
RUBY_EXTERN
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition dllexport.h:47
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:106
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:97
rb_io_printf
VALUE rb_io_printf(int argc, const VALUE *argv, VALUE io)
This is a rb_f_sprintf() + rb_io_write() combo.
Definition io.c:8544
rb_io_gets
VALUE rb_io_gets(VALUE io)
Reads a "line" from the given IO.
Definition io.c:4219
rb_cloexec_pipe
int rb_cloexec_pipe(int fildes[2])
Opens a pipe with closing on exec.
Definition io.c:409
rb_rs
VALUE rb_rs
The record separator character for inputs, or the $/.
Definition io.c:198
rb_io_print
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:8670
rb_io_addstr
VALUE rb_io_addstr(VALUE io, VALUE str)
Identical to rb_io_write(), except it always returns the passed IO.
Definition io.c:2315
rb_write_error
void rb_write_error(const char *str)
Writes the given error message to somewhere applicable.
Definition io.c:9095
rb_io_ungetbyte
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:5084
rb_io_getbyte
VALUE rb_io_getbyte(VALUE io)
Reads a byte from the given IO.
Definition io.c:4990
rb_io_puts
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:8902
rb_cloexec_dup2
int rb_cloexec_dup2(int oldfd, int newfd)
Identical to rb_cloexec_dup(), except you can specify the destination file descriptor.
Definition io.c:356
rb_io_fdopen
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:9203
rb_update_max_fd
void rb_update_max_fd(int fd)
Informs the interpreter that the passed fd can be the max.
Definition io.c:230
rb_io_write
VALUE rb_io_write(VALUE io, VALUE str)
Writes the given string to the given IO.
Definition io.c:2267
rb_cloexec_open
int rb_cloexec_open(const char *pathname, int flags, mode_t mode)
Opens a file that closes on exec.
Definition io.c:310
rb_fs
VALUE rb_fs
The field separator character for inputs, or the $;.
Definition string.c:604
rb_output_rs
VALUE rb_output_rs
The record separator character for outputs, or the $\.
Definition io.c:199
rb_io_eof
VALUE rb_io_eof(VALUE io)
Queries if the passed IO is at the end of file.
Definition io.c:2666
rb_write_error2
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:9075
rb_close_before_exec
void rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds)
Closes everything.
rb_reserved_fd_p
int rb_reserved_fd_p(int fd)
Queries if the given FD is reserved or not.
rb_fd_fix_cloexec
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:280
rb_io_flush
VALUE rb_io_flush(VALUE io)
Flushes any buffered data within the passed IO to the underlying operating system.
Definition io.c:2371
rb_io_ascii8bit_binmode
VALUE rb_io_ascii8bit_binmode(VALUE io)
Forces no conversions be applied to the passed IO.
Definition io.c:6281
rb_io_binmode
VALUE rb_io_binmode(VALUE io)
Sets the binmode.
Definition io.c:6235
rb_io_ungetc
VALUE rb_io_ungetc(VALUE io, VALUE c)
"Unget"s a string.
Definition io.c:5148
rb_pipe
int rb_pipe(int *pipes)
This is an rb_cloexec_pipe() + rb_update_max_fd() combo.
Definition io.c:7286
rb_gets
VALUE rb_gets(void)
Much like rb_io_gets(), but it reads from the mysterious ARGF object.
Definition io.c:10265
rb_cloexec_fcntl_dupfd
int rb_cloexec_fcntl_dupfd(int fd, int minfd)
Duplicates a file descriptor with closing on exec.
Definition io.c:443
rb_output_fs
VALUE rb_output_fs
The field separator character for outputs, or the $,.
Definition io.c:197
rb_file_open_str
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:7169
rb_cloexec_dup
int rb_cloexec_dup(int oldfd)
Identical to rb_cloexec_fcntl_dupfd(), except it implies minfd is 3.
Definition io.c:349
rb_file_open
VALUE rb_file_open(const char *fname, const char *fmode)
Opens a file located at the given path.
Definition io.c:7176
rb_io_close
VALUE rb_io_close(VALUE io)
Closes the IO.
Definition io.c:5671
rb_default_rs
VALUE rb_default_rs
This is the default value of rb_rs, i.e.
Definition io.c:200
RBIMPL_ATTR_NONNULL
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40