Boron 2.1.0
UPortDevice Struct Reference

The UPortDevice struct holds methods for a class of input/ouput device. More...

Data Fields

int(* open )(UThread *, const UPortDevice *, const UCell *from, int opt, UCell *res)
 Create and open a new port.
 
void(* close )(UBuffer *)
 Close port.
 
int(* read )(UThread *, UBuffer *, UCell *, int len)
 Read data from port.
 
int(* write )(UThread *, UBuffer *, const UCell *)
 Write data to port.
 
int(* seek )(UThread *, UBuffer *, UCell *, int where)
 Seek to position.
 
int defaultReadLen
 Number of bytes to read if script does not specify a length.
 

Detailed Description

The UPortDevice struct holds methods for a class of input/ouput device.

Field Documentation

◆ close

void(* UPortDevice::close) (UBuffer *)

Close port.

Parameters
pbufBuffer created by UPortDevice::open.

◆ defaultReadLen

int UPortDevice::defaultReadLen

Number of bytes to read if script does not specify a length.

This should be set to zero if UPortDevice::read does not expect a UT_BINARY or UT_STRING buffer.

◆ open

int(* UPortDevice::open) (UThread *, const UPortDevice *, const UCell *from, int opt, UCell *res)

Create and open a new port.

Parameters
pdevThis device class.
fromSpecification of port.
optPort options.
resCell for new port.
Returns
UR_OK/UR_THROW.

Open will normally call boron_makePort() to generate a port buffer and set res.

◆ read

int(* UPortDevice::read) (UThread *, UBuffer *, UCell *, int len)

Read data from port.

If UPortDevice::defaultReadLen is greater than zero then dest will reference a UT_BINARY or UT_STRING buffer with enough memory reserved for len bytes.

Parameters
pbufPort buffer created by UPortDevice::open.
destDestination buffer or result.
lenNumber of bytes to read into dest.
Returns
UR_OK/UR_THROW

◆ seek

int(* UPortDevice::seek) (UThread *, UBuffer *, UCell *, int where)

Seek to position.

Parameters
pbufBuffer created by UPortDevice::open.
posNew position relative to where.
whereSEEK_SET, SEEK_END, or SEEK_CUR.
Returns
UR_OK/UR_THROW

If the device cannot seek then call ur_error().

◆ write

int(* UPortDevice::write) (UThread *, UBuffer *, const UCell *)

Write data to port.

Parameters
pbufBuffer created by UPortDevice::open.
dataData to write.
Returns
UR_OK/UR_THROW

The documentation for this struct was generated from the following files: