Guardian C Library Calls Reference Manual

Reference to Library Calls
Guardian TNS C Library Calls Reference Manual128833 3-111
lseek (supplementary)
lseek (supplementary)
The lseek function sets the file-position indicator of a byte-addressable file opened for
alternate I/O.
file_des
is the descriptor denoting a file opened for alternate I/O.
pos
is a long value specifying the desired position.
pos_base
specifies whether pos denotes an offset from the beginning, current position, or end
of the file. You specify the pos_base by using one of the following object-like
macros:
SEEK_SET indicates that the offset is relative to the beginning of the file.
SEEK_CUR indicates that the offset is relative to the current file position.
SEEK_END indicates that the offset is relative to the end of the file.
Return Value
is the new file position if the operation is successful or -1 if an error occurs.
Usage Guidelines
The lseek function has no effect if the file is a device (a terminal, for example).
Example
In this example, the lseek function sets the file-position indicator to the beginning of the
file:
#include <fcntlh>
int filedes, pos_base;
long status, pos;
filedes = open ("$a.b.c");
/* ... */
pos = 0;
pos_base = SEEK_SET;
status = lseek(filedes, pos, pos_base);
#include <fcntlh>
long lseek(int file_des, long pos, int pos_base);