NAME ^

src/io/name.c - Win32 IO layer

DESCRIPTION ^

This is the Parrot OS-specific IO layer for Win32 platforms.

References ^

Win32 System Programming, 2nd Edition.

Functions ^

static INTVAL flags_to_win32(INTVAL flags, NOTNULL(DWORD *fdwAccess), NOTNULL(DWORD *fdwShareMode), NOTNULL(DWORD *fdwCreate))

Convert to platform-specific bit open flags.

static INTVAL PIO_win32_init(PARROT_INTERP, NOTNULL(ParrotIOLayer *layer))

Sets up the standard std* IO handles.

INTVAL PIO_win32_getblksize(SHIM(PIOHANDLE fd))

Returns PIO_BLKSIZE.

PARROT_CAN_RETURN_NULL static ParrotIO *PIO_win32_open(PARROT_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(const char *spath), INTVAL flags)

Calls CreateFile() to open *spath with the Win32 translation of flags.

PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL static ParrotIO *PIO_win32_fdopen(PARROT_INTERP, SHIM(ParrotIOLayer *layer), PIOHANDLE fd, INTVAL flags)

Returns a new ParrotIO with fd as its file descriptor.

static INTVAL PIO_win32_close(SHIM_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(ParrotIO *io))

Calls CloseHandle() to close *io's file descriptor.

PARROT_WARN_UNUSED_RESULT static INTVAL PIO_win32_isatty(PIOHANDLE fd)

Returns whether fd is a console/tty.

static INTVAL PIO_win32_flush(SHIM_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(ParrotIO *io))

Calls FlushFileBuffers() to flush *io's file descriptor.

static size_t PIO_win32_read(PARROT_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(ParrotIO *io), NOTNULL(STRING **buf))

Calls ReadFile() to read up to len bytes from *io's file descriptor to the memory starting at buffer.

static size_t PIO_win32_write(SHIM_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(ParrotIO *io), NOTNULL(STRING *s))

Calls WriteFile() to write len bytes from the memory starting at buffer to *io's file descriptor.

static PIOOFF_T PIO_win32_seek(SHIM_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(ParrotIO *io), PIOOFF_T off, INTVAL whence)

Hard seek.

Calls SetFilePointer() to move the read/write position of *io's file descriptor to off bytes relative to the location specified by whence.

static PIOOFF_T PIO_win32_tell(SHIM_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(ParrotIO *io))

Returns the current read/write position of *io's file descriptor.

PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL STRING *PIO_sockaddr_in(PARROT_INTERP, unsigned short port, NOTNULL(STRING *addr))

PIO_sockaddr_in() is not part of the layer and so must be extern.

XXX: We can probably just write our own routines (htons(), inet_aton(), etc.) and take this out of platform specific compilation

PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL static ParrotIO *PIO_win32_socket(PARROT_INTERP, SHIM(ParrotIOLayer *layer), int fam, int type, int proto)

Uses socket() to create a socket with the specified address family, socket type and protocol number.

static INTVAL PIO_win32_connect(PARROT_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(ParrotIO *io), NOTNULL(STRING *r))

Connects *io's socket to address *r.

static INTVAL PIO_win32_send(SHIM_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(ParrotIO *io), NOTNULL(STRING *s))

Send the message *s to *io's connected socket.

static INTVAL PIO_win32_recv(PARROT_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(ParrotIO *io), NOTNULL(STRING **s))

Receives a message in **s from *io's connected socket.

static INTVAL PIO_win32_bind(PARROT_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(ParrotIO *io), NULLOK(STRING *l))

Binds *io's socket to the local address and port specified by *l.

static INTVAL PIO_win32_listen(SHIM_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(ParrotIO *io), INTVAL backlog)

Listen for new connections. This is only applicable to STREAM or SEQ sockets.

PARROT_CAN_RETURN_NULL static ParrotIO *PIO_win32_accept(PARROT_INTERP, SHIM(ParrotIOLayer *layer), NOTNULL(ParrotIO *io))

Accept a new connection and return a newly created ParrotIO socket.

SEE ALSO ^

src/io/io_buf.c, src/io/io_passdown.c, src/io/io_stdio.c, src/io/io_unix.c, src/io/io.c, src/io/io_private.h.

HISTORY ^

Initially written by Melvin Smith.


parrot