FSU_FSEEK(3)

NAME
fsu_fseek, fsu_fseeko, fsu_fsetpos, fsu_ftell, fsu_ftello, fsu_rewind - reposition a stream

LIBRARY
fsu_utils Library (libfsu_utils, -lfsu_utils)

SYNOPSIS
#include <fsu_utils.h>
int
fsu_fseek(FSU_FILE *stream, long int offset, int whence);
int
fsu_fseeko(FSU_FILE *stream, off_t offset, int whence);
long int
fsu_ftell(FSU_FILE *stream);
off_t
fsu_ftello(FSU_FILE *stream);
void
fsu_rewind(FSU_FILE *stream);

DESCRIPTION
The fsu_fseek() function sets the file position indicator for the stream pointed to by stream. The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence. If whence is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to the start of the file, the current position indicator, or end-of-file, respectively. A successful call to the fsu_fseek() function clears the end-of-file indicator for the stream.

The fsu_fseeko() function is identical to the fsu_fseek() function except that the offset argument is of type off_t.

The fsu_ftell() function obtains the current value of the file position indicator for the stream pointed to by stream.

The fsu_ftello() function is identical to the ftell() function except that the return value is of type off_t.

The fsu_rewind() function sets the file position indicator for the stream pointed to by stream to the beginning of the file. It is equivalent to:

    (void)fsu_fseek(stream, 0L, SEEK_SET)

except that the error indicator for the stream is also cleared (see fsu_clearerr(3)).

RETURN VALUES
The fsu_rewind() function returns no value. Upon successful completion, fsu_fseek() returns 0, and fsu_ftell() returns the current offset. Otherwise, fsu_fseek() and fsu_ftell() return -1 and the others return a nonzero value and the global variable errno is set to indicate the error.

ERRORS

[EBADF]
    The stream specified is not a seekable stream.

[EINVAL]
    The whence argument to fsu_fseek() was not SEEK_SET, SEEK_END, or SEEK_CUR.

The functions fsu_fseek(), fsu_fseeko(), fsu_ftell(), fsu_ftello(), and fsu_rewind() may also fail and set errno for any of the errors specified for the routines fsu_fflush(3), and malloc(3).

SEE ALSO
ukfs(3)