Add ftello function
This commit is contained in:
		
							parent
							
								
									a3e4dcafe0
								
							
						
					
					
						commit
						551374c228
					
				| @ -120,6 +120,7 @@ _PROTOTYPE( int fseek, (FILE *_stream, long _offset, int _whence)	); | |||||||
| _PROTOTYPE( int fseeko, (FILE *_stream, off_t _offset, int _whence)	); | _PROTOTYPE( int fseeko, (FILE *_stream, off_t _offset, int _whence)	); | ||||||
| _PROTOTYPE( int fsetpos, (FILE *_stream, fpos_t *_pos)			); | _PROTOTYPE( int fsetpos, (FILE *_stream, fpos_t *_pos)			); | ||||||
| _PROTOTYPE( long ftell, (FILE *_stream)					); | _PROTOTYPE( long ftell, (FILE *_stream)					); | ||||||
|  | _PROTOTYPE( off_t ftello, (FILE *_stream)				); | ||||||
| _PROTOTYPE( void rewind, (FILE *_stream)				); | _PROTOTYPE( void rewind, (FILE *_stream)				); | ||||||
| _PROTOTYPE( void clearerr, (FILE *_stream)				); | _PROTOTYPE( void clearerr, (FILE *_stream)				); | ||||||
| _PROTOTYPE( int feof, (FILE *_stream)					); | _PROTOTYPE( int feof, (FILE *_stream)					); | ||||||
|  | |||||||
| @ -3,6 +3,7 @@ | |||||||
|  */ |  */ | ||||||
| /* $Header$ */ | /* $Header$ */ | ||||||
| 
 | 
 | ||||||
|  | #include	<assert.h> | ||||||
| #include	<stdio.h> | #include	<stdio.h> | ||||||
| 
 | 
 | ||||||
| #if	(SEEK_CUR != 1) || (SEEK_SET != 0) || (SEEK_END != 2) | #if	(SEEK_CUR != 1) || (SEEK_SET != 0) || (SEEK_END != 2) | ||||||
| @ -16,6 +17,12 @@ | |||||||
| off_t _lseek(int fildes, off_t offset, int whence); | off_t _lseek(int fildes, off_t offset, int whence); | ||||||
| 
 | 
 | ||||||
| long ftell(FILE *stream) | long ftell(FILE *stream) | ||||||
|  | { | ||||||
|  | 	assert(sizeof(long) == sizeof(off_t)); | ||||||
|  | 	return (long) ftello(stream); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | off_t ftello(FILE *stream) | ||||||
| { | { | ||||||
| 	long result; | 	long result; | ||||||
| 	int adjust = 0; | 	int adjust = 0; | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ | |||||||
| .TH FSEEK 3  "February 24, 1986" | .TH FSEEK 3  "February 24, 1986" | ||||||
| .AT 3 | .AT 3 | ||||||
| .SH NAME | .SH NAME | ||||||
| fseek, fseeko, ftell, rewind \- reposition a stream | fseek, fseeko, ftell, ftello, rewind \- reposition a stream | ||||||
| .SH SYNOPSIS | .SH SYNOPSIS | ||||||
| .nf | .nf | ||||||
| .ft B | .ft B | ||||||
| @ -12,6 +12,7 @@ fseek, fseeko, ftell, rewind \- reposition a stream | |||||||
| int fseek(FILE *\fIstream\fP, long \fIoffset\fP, int \fIptrname\fP) | int fseek(FILE *\fIstream\fP, long \fIoffset\fP, int \fIptrname\fP) | ||||||
| int fseeko(FILE *\fIstream\fP, off_t \fIoffset\fP, int \fIptrname\fP) | int fseeko(FILE *\fIstream\fP, off_t \fIoffset\fP, int \fIptrname\fP) | ||||||
| long ftell(FILE *\fIstream\fP) | long ftell(FILE *\fIstream\fP) | ||||||
|  | off_t ftello(FILE *\fIstream\fP) | ||||||
| void rewind(FILE *\fIstream\fP) | void rewind(FILE *\fIstream\fP) | ||||||
| .ft R | .ft R | ||||||
| .fi | .fi | ||||||
| @ -37,7 +38,9 @@ undo any effects of | |||||||
| .BR  ungetc (3). | .BR  ungetc (3). | ||||||
| .PP | .PP | ||||||
| .B Ftell | .B Ftell | ||||||
| returns the current value of the offset relative to the beginning | and | ||||||
|  | .B ftello | ||||||
|  | return the current value of the offset relative to the beginning | ||||||
| of the file associated with the named | of the file associated with the named | ||||||
| .IR stream . | .IR stream . | ||||||
| It is measured in bytes on UNIX; | It is measured in bytes on UNIX; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Erik van der Kouwe
						Erik van der Kouwe