FFSEEK(3C) Last changed: 2-18-98
ffseek, ffbksp, ffseekf, ffbkspf - Repositions a flexible file I/O
file
#include <ffio.h>
#include <unistd.h>
UNICOS and UNICOS/mk systems:
int ffseek (int fd, off_t pos, int whence [, struct ffsw *stat]);
int ffbksp (int fd [, struct ffsw *stat]);
IRIX systems:
off_t ffseek (int fd, off_t pos, int whence);
int ffbksp (int fd);
All systems:
off_t ffseekf (int fd, off_t pos, int whence, struct ffsw *stat);
int ffbkspf (int fd, struct ffsw *stat);
UNICOS, UNICOS/mk, and IRIX systems
The ffseek function provides flexible file I/O (FFIO) positioning
capability similar to that of lseek(2). In addition to the
functionality of lseek, ffseek provides access to limited positioning
on blocked files and record-oriented files. Specifying ffseek(fd, 0,
0) always rewinds a file to its initial point, regardless of whether
the file is stream, blocked, or tape. When using the syscall layer,
this function cannot be used to position a tape.
This function allows programs to be written so that their I/O can be
controlled by the asgcmd(1) or assign(1) command. Both native and
foreign record-oriented I/O, multifile datasets, and
performance-oriented layers (such as SDS resident layers and
memory-resident layers) are available with this mechanism.
Function ffbksp allows you to perform a backspace operation on those
FFIO layers that support it. Currently, this is limited to cos, tape,
f77, and text.
Arguments are as follows:
fd Number returned by ffopen(3C).
pos Byte position requested.
whence Specifies one of the following values (defined in header file
stdio.h):
0 or SEEK_SET Sets the pointer to the value of pos.
pos must be a non-negative integer.
(Special case: ffseek(fd, 0, 0) =
rewind)
1 or SEEK_CUR Sets the pointer to the current position,
plus or minus *arg. This is supported
only in layers that are not
record-oriented; layers are specified to
assign -F as follows: syscall, sds, mr
(memory resident), cache, cachea, bufa,
er90.
2 or SEEK_END Sets the pointer to the end of the file,
minus pos. pos must be a non-negative
integer. Not all layers support this
option. (Special case: ffseek(fd, 0, 2)
= position just in front of the EOD.)
stat Pointer to the ffsw status return structure.
The return value is the current position in the file after the seek.
Upon successful completion, a non-negative value is returned.
Otherwise, -1 is returned, and, if the stat parameter is passed, the
error value is found in stat.sw_error. If the stat parameter is not
provided, the error code is found in errno.
#include <stdlib.h>
#include <fcntl.h>
#include <stdio.h>
#include <ffio.h>
main()
{
size_t ret;
int fd, i, j;
off_t fret;
fd = ffopen("data", O_RDWR | O_CREAT, 0666);
for (i = 0 ; i < 1000 ; i++)
{
ret = ffwrite(fd, &i, sizeof(i));
if (ret < 0) abort();
}
for (i = 0 ; i < 10 ; i++)
{
fret = ffseek(fd, i * sizeof(j) * 100, SEEK_SET);
if (fret < 0) abort();
ret = ffread(fd, &j, sizeof(j));
if (ret < 0) abort();
printf("Value is %d at word %d\n", j, i*100);
}
}
Output from the previous program is as follows:
Value is 0 at word 0
Value is 100 at word 100
Value is 200 at word 200
Value is 300 at word 300
Value is 400 at word 400
Value is 500 at word 500
Value is 600 at word 600
Value is 700 at word 700
Value is 800 at word 800
Value is 900 at word 900
errno.h(3C), ffclose(3C), ffopen(3C), ffread(3C), ffwrite(3C)
Application Programmer's Library Reference Manual, publication
SR-2165, for the printed version of this man page.
[ Back ]
|