device-write

Generic Function

Package: excl

Arguments: stream buffer start end blocking

If buffer is nil, and start and end are not eql, then the appropriate buffer slot must be used as the buffer to write from. Any manipulation of buffers, including replacement of the buffer slot with a new one of the same size, can be done before returning.

An attempt is made to transfer data from the buffer to the device specified by stream from start to end. The number of octets (8-bit bytes) actually written is returned, or else an error or other exceptional situation encode in the following way:

The blocking argument allows asynchronous writes. If blocking is true, then the write waits until the operation is done (or, if the scheduler is running, the thread waits until output can be finished, allowing other threads to continue meanwhile). If blocking is nil, then the write transfers as much as it can immediately and returns the number of bytes written.

buffer may be a vector of any size and element-type. If the element-type is not octet (8-bit byte, signed or unsigned) then the endianness order of bits or bytes is that of the natural order of the native machine. Thus, with an element-type of (unsigned-byte 32) on a little-endian machine, a write of the value #x12345678 will result in the byte stream #x78, #x56, #x34, #x12, whereas on a big-endian machine the resulting byte stream will be #x12, #x34, #x56, #x78.

Note that no checking is done to match byte-counts to element-widths. It is up to the strategy-level programmer (see the end of section Simple-stream Description) to ensure that endianness is matched against the stream, and that data widths are sent as expected.

The output-handle slot of stream can either be an operating-system file descriptor/handle, or another stream. If it is another stream, then device-write performs the equivalent of a write-vector on that stream, instead of getting the data from the operating system. Arguments and return values are adjusted to agree with the interfaces between device-write and write-vector.

Defined methods

Note that the supplied device-read and device-write functions do not generate errors themselves, but pass them back to the higher level for processing. This allows read-octets and write-octets to pass errors back as well, as the implementation of a higher level (encapsulating) device-read and device-write.

See streams.htm for information on the simple-streams implementation in Allegro CL. The older but still supported Gray streams implementation is described in gray-streams.htm.

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.