NAME
src/io/api.c - Parrot I/O API
DESCRIPTION
The Parrot I/O subsystem provides the core I/O functionality for all parts of Parrot. This file implements the public interface to the I/O subsystem. Common utility functions that aren't part of the public interface are defined in src/io/common.c and utility functions for a specific platform are in src/io/unix.c, src/io/win32.c, or src/io/portable.c. The platform is selected in include/parrot/io.h, based on #defines from the configuration process.
The FileHandle PMC provides the class-based interface for filehandles that is used in Parrot ops.
Generic I/O interface
PMC *Parrot_io_stdhandle
Get the current standard IO object and optionally set a new one.
PMC *Parrot_io_new_pmc
Creates a new I/O filehandle object.
The value of PMC *Parrot_io_open
Return an open filehandle for a given string path and flags.
Defaults to creating a new FileHandle PMC.
If a PMC object is passed in,
it uses that object instead of creating a new FileHandle.
PMC *Parrot_io_fdopen
Creates and returns a INTVAL Parrot_io_close
Closes the filehandle object.
INTVAL Parrot_io_is_closed
Test whether a filehandle is closed.
void Parrot_io_flush
Flushes the STRING *Parrot_io_reads
Return a new STRING *Parrot_io_readline
Return a new INTVAL Parrot_io_write
Writes PIOOFF_T Parrot_io_seek
Moves the read/write position of PIOOFF_T Parrot_io_tell
Returns the current read/write position of INTVAL Parrot_io_peek
Retrieve the next character in the stream without modifying the stream.
Calls the platform-specific implementation of 'peek'.
INTVAL Parrot_io_eof
Returns a boolean value indication whether INTVAL Parrot_io_puts
Writes INTVAL Parrot_io_putps
Writes INTVAL Parrot_io_fprintf
Writes a C string format with varargs to INTVAL Parrot_io_printf
Writes a C string format with varargs to INTVAL Parrot_io_eprintf
Writes a C string format with varargs to PIOHANDLE Parrot_io_getfd
Returns INTVAL Parrot_io_is_tty
Returns a boolean value indicating whether
flags is set in the returned PMC.
FileHandle PMC for a given set of flags on an existing,
open file descriptor.This is used particularly to initialize the STD* IO handles onto the OS IO handles (0,
1,
2).
ParrotIO PMC *pmc.
STRING* holding up to len bytes.
STRING* holding the next line read from the file.
len bytes from *buffer to *pmc.
*pmc to offset bytes from the position indicated by w.
Typically w will be 0 for the start of the file,
1 for the current position,
and 2 for the end.
*pmc.
*pmc's current read/write position is EOF.
*s tp *pmc.
C string version.
*s to *pmc.
Parrot string version.
*pmc.
stdout.
stderr.
*pmc's file descriptor,
or 0 if it is not defined.
*pmc is a console/tty.Parrot_io_STD* Functions
PMC *Parrot_io_STDIN
Returns the PMC *Parrot_io_STDOUT
Returns the PMC *Parrot_io_STDERR
Returns the
FileHandle PMC for stdin.
FileHandle PMC for stdout.
FileHandle PMC for stderr.Offset Functions
These are used to create offsets for the seek op.
PIOOFF_T Parrot_io_make_offset
Returns PIOOFF_T Parrot_io_make_offset32PIOOFF_T Parrot_io_make_offset_pmc
Returns the return value of the
offset.
hi is shifted 32 bytes to the left and ored together with lo.
This allows 64-bit seeks with only 32-bit INTVALS.
get_integer vtable method on *pmc.SEE ALSO
io/unix.c, io/win32.c, io/portable.c, io/io_private.h.