From: Erik van der Kouwe Date: Mon, 16 Aug 2010 17:06:08 +0000 (+0000) Subject: Add fseeko function X-Git-Tag: v3.1.8~71 X-Git-Url: http://zhaoyanbai.com/repos/man.host.html?a=commitdiff_plain;h=a3e4dcafe03612b5d9920beb27fa4994c1666c82;p=minix.git Add fseeko function --- diff --git a/include/stdio.h b/include/stdio.h index 30559d0d9..0e61090b2 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -117,6 +117,7 @@ _PROTOTYPE( size_t fwrite, (const void *_ptr, size_t _size, size_t _nmemb, FILE *_stream) ); _PROTOTYPE( int fgetpos, (FILE *_stream, fpos_t *_pos) ); _PROTOTYPE( int fseek, (FILE *_stream, long _offset, int _whence) ); +_PROTOTYPE( int fseeko, (FILE *_stream, off_t _offset, int _whence) ); _PROTOTYPE( int fsetpos, (FILE *_stream, fpos_t *_pos) ); _PROTOTYPE( long ftell, (FILE *_stream) ); _PROTOTYPE( void rewind, (FILE *_stream) ); diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c index 4e0d70948..ef6d47259 100644 --- a/lib/libc/stdio/fseek.c +++ b/lib/libc/stdio/fseek.c @@ -3,6 +3,7 @@ */ /* $Header$ */ +#include #include #if (SEEK_CUR != 1) || (SEEK_END != 2) || (SEEK_SET != 0) @@ -17,6 +18,13 @@ off_t _lseek(int fildes, off_t offset, int whence); int fseek(FILE *stream, long int offset, int whence) +{ + assert(sizeof(offset) == sizeof(off_t)); + return fseeko(stream, (off_t) offset, whence); +} + +int +fseeko(FILE *stream, off_t offset, int whence) { int adjust = 0; long pos; diff --git a/man/man3/fseek.3 b/man/man3/fseek.3 index fe863bdac..53d22561a 100644 --- a/man/man3/fseek.3 +++ b/man/man3/fseek.3 @@ -3,20 +3,23 @@ .TH FSEEK 3 "February 24, 1986" .AT 3 .SH NAME -fseek, ftell, rewind \- reposition a stream +fseek, fseeko, ftell, rewind \- reposition a stream .SH SYNOPSIS .nf .ft B #include int fseek(FILE *\fIstream\fP, long \fIoffset\fP, int \fIptrname\fP) +int fseeko(FILE *\fIstream\fP, off_t \fIoffset\fP, int \fIptrname\fP) long ftell(FILE *\fIstream\fP) void rewind(FILE *\fIstream\fP) .ft R .fi .SH DESCRIPTION .B Fseek -sets the position of the next input or output +and +.B fseeko +set the position of the next input or output operation on the .IR stream . The new position is at the signed distance @@ -28,7 +31,9 @@ according as has the value 0, 1, or 2. .PP .B Fseek -undoes any effects of +and +.B fseeko +undo any effects of .BR ungetc (3). .PP .B Ftell @@ -40,7 +45,9 @@ on some other systems it is a magic cookie, and the only foolproof way to obtain an .I offset for -.BR fseek . +.BR fseek +and +.BR fseeko . .PP .BR Rewind "(\fIstream\fR)" is equivalent to @@ -50,4 +57,6 @@ is equivalent to .BR fopen (3). .SH DIAGNOSTICS .B Fseek -returns \-1 for improper seeks, otherwise zero. +and +.B fseeko +return \-1 for improper seeks, otherwise zero.