spio_t_error_code user_write( void *user_data, void const *buf, size_t *pbuf_size, spio_t_bits write_options );
This is the prototype for one of the methods of user defined streams. It is used when SICStus wants to write data to the user defined stream.
The same value as was passed to
Points to a buffer allocated by the caller containing the data to be written.
Points to the size of the buffer, always positive. When this function
*pbuf_size should be set to the number of
bytes actually written, which should always be positive for
Note that buffer size is measured in bytes also for text streams.
The following bits can be set:
This is always specified if the device was created as a binary
device. The buffer contains
This is always specified if the device was created as a text
device. The buffer contains wide characters, i.e.
spio_t_wchar. Note that
*buf_size is size in
bytes, not in characters.
If this is set, the function should return quickly,
either with some data written or with a
user_write will never block, you can ignore this value.
You should return
cannot support non-blocking write.
*pbuf_size should be assigned to with the number of
bytes written and
SPIO_S_NOERR or some other success code
returned. On success, something must have been written, e.g.
*pbuf_size must be set to a positive value.
On failure, return a SPIO error code. Error codes with special meaning
Returned if it is not possible to write more data onto the stream, e.g. some underlying device has been closed.
SPIO_DEVICE_WRITE_OPTION_NONBLOCKING was set but the operation
Some unsupported option, e.g.
SPIO_DEVICE_WRITE_OPTION_NONBLOCKING, was passed.
Other error codes may also be returned.
Should write up to
*buf_size bytes of data from
buf. Data could be either bytes, for a binary device, or wide
characters, for a text device.
cpg-ref-SP_create_stream. Defining a New Stream.