Guardian C Library Calls Reference Manual
edlseek (supplementary)
3-30 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
edlseek (supplementary)
The edlseek function sets the file-position indicator of an Edit file opened for
alternate I/O to the beginning of the line that you request.
file_des
is the descriptor denoting an Edit file opened for alternate I/O.
pos
specifies the desired file position. Depending on pos_base, the file position is either
a line number or a line offset.
pos_base
is one of the following alternatives:
•
SEEK_SET indicates that pos is a line number. The file is positioned at the first line
whose line number is greater than or equal to the line number requested.
•
SEEK_CUR indicates that pos is the number of lines from the file-position
indicator; pos can be positive or negative.
•
SEEK_END indicates that pos is the number of lines from the end of the file; pos
can be either zero or negative. If pos is zero, the file is positioned at the next line to
be written–that is, at the end of the file. If it is negative, pos specifies how many
lines to skip backwards.
Return Value
is the line number if the operation is successful; otherwise, edlseek returns the
value -1 and sets errno to the Guardian error number.
Usage Guidelines
•
The edlseek function resets the end-of-file and error indicators.
•
If you specify a line beyond the last line in the file, the file is positioned at the
beginning of the next line to be written to the file. If you specify a line before the
first line in the file, the file is positioned at the beginning of the first line.
•
Relative positioning (using pos_base values SEEK_CUR or SEEK_END) is slower
than absolute positioning (using pos_base value SEEK_SET) because it requires
sequential scanning of the file.
•
For absolute positioning (using pos_base value SEEK_SET), pos is the Edit line
number multiplied by 1000. For example, 23000L corresponds to line 23, and
44120L corresponds to line 44.12.
#include <fcntlh>
long edlseek(short file_des, long pos, short pos_base);