STOpen(3) Impressario STOpen(3)NAME
STOpen, STClose - open/close a STIFF file stream
SYNOPSIS
#include <stdio.h>
#include <stiff.h>
STStream* STOpen(int fd, int flags);
int STClose(STStream *st);
DESCRIPTION
STOpen opens a STIFF stream for the specified file descriptor. The
STStream pointer returned by STOpen is a handle used by many libstiff
functions. fd is a file descriptor obtained from a system call such as
open(2), pipe(2), or socket(2), or from a call to fileno(3S). The flags
parameter specifies how the STIFF stream should be opened. Specifying
flags as ST_READ opens the stream for reading. Specifying ST_WRITE opens
the stream for writing. The value specified for flags should agree with
the file descriptor's open mode. That is, if fd is a read-only
descriptor, flags should be ST_READ. libstiff does not support reading
and writing on the same stream.
STClose writes a terminating empty IFD (if st was open for writing) and
closes the STIFF stream previously opened by a call to STOpen.
RETURN VALUE
STOpen returns a pointer to a newly opened STIFF stream if execution was
successful. NULL is returned and STerrno is set if an execution error has
occurred.
STClose returns 0 if execution was successful. -1 is returned and STerrno
is set if an execution error has occurred.
WARNING
STIFF stream information is maintained with the STStream structure by the
libstiff functions. For this reason all reading and writing to a STIFF
stream should be done using only libstiff functions. Use of other
functions (e.g. write(2)) to perform STIFF stream I/O will lead to
unexpected results and is strongly discouraged.
EXECUTION ERROR CODES
STOpen will fail under the following circumstances.
STEBADSTREAM Invalid STIFF stream.
STEWRITETOREAD Attempt to write to a read only stream.
STEREADFROMWRITE Attempt to read from a write stream.
Page 1
STOpen(3) Impressario STOpen(3)
STESYSCALL System call failed.
STClose will fail under the following circumstances.
STENEEDSEEK Operation requires seeking on a stream.
STESYSCALL System call failed.
SEE ALSOlibstiff(3).
Page 2