Unison Help
![](https://rowebots.com/wp-content/plugins/documentor/skins/default/images/search.png)
- Unison Kernel
- Pthreads
- pthread_create()
- pthread_exit()
- pthread_self()
- pthread_equal()
- pthread_join()
- pthread_detach()
- pthread_setschedparam()
- pthread_getschedparam()
- pthread_attr_init()
- pthread_attr_destroy()
- pthread_attr_setstackaddr()
- pthread_attr_getstackaddr()
- pthread_attr_setstacksize()
- pthread_attr_getstacksize()
- pthread_attr_setschedparam()
- pthread_attr_getschedparam()
- pthread_attr_setdetachstate()
- pthread_attr_getdetachstate()
- pthread_stackinfo()
- pthread_setprio()
- pthread_getprio()
- sched_get_priority_max()
- sched_get_priority_min()
- sched_yield()
- Pthread Cancellation
- Mutex
- Semaphores
- Message Queues
- Conditional Variables
- Barriers
- Timers
- Clocks
- Memory Allocation
- Rendezvous
- Interrupts
- Directory Services
- Miscellaneous
- Pthreads
- Unison I/O Library
- Unison STDIO Library
- STDIO Library Calls
- clearerr()
- dprintf()
- fclose()
- fdopen()
- feof()
- ferror()
- fileno()
- fflush()
- fgetc()
- fgetpos()
- fgets()
- fopen()
- fprintf()
- fputc()
- fputs()
- fread()
- freopen()
- fscanf()
- fseek()
- fseeko()
- fsetpos()
- ftell()
- ftello()
- fwrite()
- getc()
- getc_unlocked()
- getchar()
- getchar_unlocked()
- getdelim()
- getline()
- gets()
- get_stderr_ptr()
- get_stdin_ptr()
- get_stdout_ptr()
- noperprintf()
- perprintf()
- perror()
- posix_compat()
- printf()
- putc()
- putc_unlocked()
- putchar()
- putchar_unlocked()
- puts()
- remove()
- rewind()
- scanf()
- setbuf()
- setvbuf()
- snprintf()
- sprintf()
- sscanf()
- stderr_init()
- stderr_close()
- stdin_init()
- stdin_close()
- stdout_init()
- stdout_close()
- vdprintf()
- vscanf()
- vsscanf()
- vfscanf()
- vprintf()
- vsnprintf()
- vsprintf()
- vfprintf()
- ungetc()
- Do-nothing Stubs
- STDIO Library Calls
- Unison LIBC Library
- Unison I/O Servers
- Graphics, Camera, Video, Audio
- Network Protocols
- TCP and UDP Server - tcpd
- DHCP Client Service - dhcp client
- DHCP Server - dhcpd
- Telnet Server - telnetd
- Tiny FTP Server - tftpd
- Point to Point - pppd
- Network Translation - NAT with PAT
- Firewall
- Tiny HTTP Server - thttpd
- Tiny HTTP Server with TLS
- POP3 Server
- Simple Mail Transfer Protocol Services (SMTP)
- Bootp Protocol
- File Transfer Protocol Server (FTP)
- File Transfer Client Services
- RPC / XDR
- DNS Client
- HTTP/HTTPS Client
- REST Client
- AutoIP Service - autoip client
- mDNS server - mdnsd
- SNTP Client
- SNMP Agent - Snmpd server
- SSL/TLS library
- SSH server
- IP security
- Power Control
- Serial I/O
- System Services
- Universal Serial Bus (USB)
- Wireless
- Remedy Tools for Unison
3.1.46.rewind() #
NAME
fseek, fseeko, rewind, ftell, ftello – reposition a file pointer in a stream
SYNOPSIS
#include <stdio.h>
- int fseek( FILE *stream, long offset, int where );
int fseeko( FILE *stream, off_t offset, int where ); - void rewind( FILE *stream );
- long ftell( FILE *stream );
off_t ftello( FILE *stream );
DESCRIPTION
fseek()/fseeko() sets the position of the next input or output operation on the stream. The new position is at the signed distance offset bytes from the beginning, from the current position, or from the end of the file, according to a where value of SEEK_SET, SEEK_CUR, or SEEK_END (defined in <stdio.h>) as follows:
- SEEK_SET
- set position equal to offset bytes.
- SEEK_CUR
- set position to current location plus offset.
- SEEK_END
- set position to EOF plus offset.
fseek()/fseeko() allows the file position indicator to be set beyond the end of the existing data in the file. If data is later written at this point, subsequent reads of data in the gap will return zero until data is actually written into the gap. fseek()/fseeko(), by itself, does not extend the size of the file.
rewind(stream) is equivalent to: (void)fseek(stream, 0L, SEEK_SET); except that rewind() also clears the error indicator on stream.
fseek()/fseeko() and rewind() clear the EOF indicator and undo any effects of ungetc() on stream. After fseek()/fseeko() or rewind() , the next operation on a file opened for update may be either input or output.
If stream is writable and buffered data has not been written to the underlying file, fseek()/fseeko() and rewind() cause the unwritten data to be written to the file.
ftell()/ftello() returns the offset of the current byte relative to the beginning of the file associated with the named stream .
RETURN VALUES
fseek()/fseeko() returns -1 for improper seeks, otherwise zero. An improper seek can be, for example, an fseek()/fseeko() done on a file that has not been opened via fopen(). After a stream is closed, no further operations are defined on that stream.
ftell()/ftello() returns the current value of the file-position indicator for the stream measured in bytes from the beginning of the file. Otherwise, returns -1 cast to long, and off_t respectively, and set errno to indicate the error.
ERRORS
These functions are members of Unison’s STDIO implementation. The STDIO implementation rests on top of IOLIB and inherits IOLIB’s dependency on each specific server to report an appropriate error code for its usage.
For an exact list of error codes returned by a particular server, refer to that server’s documentation in the Unison Programmer’s Guide for each specific platform.
Servers may implement these errors codes in response to this function.
For fseek()/fseeko() and rewind():
- [EAGAIN]
- The O_NONBLOCK flag is set for the file descriptor and the thread would be delayed in the write operation.
- [EBADF]
- The file descriptor underlying the stream file is not open for writing or the stream’s buffer needed to be flushed and the file is not open.
- [EFBIG]
- An attempt was made to write a file that exceeds the maximum file size.
- [EINVAL]
- The whence argument is invalid. The resulting file-position indicator would be set to a negative value.
- [EIO]
- A physical I/O error has occurred, or the process is a member of a background process group attempting to perform a write() to its controlling terminal, TOSTOP is set, the process is neither ignoring nor blocking SIGTTOU, and the process group of the process is orphaned. This error may also be returned under implementation-defined conditions.
- [ENOSPC]
- There was no free space remaining on the device containing the file.
- [ENXIO]
- A request was made of a nonexistent device, or the request was outside the capabilities of the device.
For ftell()/ftello():
- [EBADF]
- The file descriptor underlying stream is not an open file descriptor.
SEE ALSO
lseek(), write(), fopen(), ungetc()
NOTES
Although on the UNIX system an offset returned by ftell()/ftello() is measured in bytes, and it is permissible to seek to positions relative to that offset, portability to non-UNIX systems requires that an offset be used by fseek()/fseeko() directly. Arithmetic may not meaningfully be performed on such an offset, which is not necessarily measured in bytes.