genericopenlibs/cstdlib/LSTDIO/REWIND.C
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /* REWIND.C
       
     2  * 
       
     3  * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies).
       
     4  * All rights reserved.
       
     5  */
       
     6 
       
     7 /*
       
     8  * Copyright (c) 1990 The Regents of the University of California.
       
     9  * All rights reserved.
       
    10  *
       
    11  * Redistribution and use in source and binary forms are permitted
       
    12  * provided that the above copyright notice and this paragraph are
       
    13  * duplicated in all such forms and that any documentation,
       
    14  * advertising materials, and other materials related to such
       
    15  * distribution and use acknowledge that the software was developed
       
    16  * by the University of California, Berkeley.  The name of the
       
    17  * University may not be used to endorse or promote products derived
       
    18  * from this software without specific prior written permission.
       
    19  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
       
    20  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
       
    21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
       
    22  */
       
    23 
       
    24 /*
       
    25 FUNCTION
       
    26 <<rewind>>---reinitialize a file or stream
       
    27 
       
    28 INDEX
       
    29 	rewind
       
    30 
       
    31 ANSI_SYNOPSIS
       
    32 	#include <stdio.h>
       
    33 	void rewind(FILE *<[fp]>);
       
    34 
       
    35 TRAD_SYNOPSIS
       
    36 	#include <stdio.h>
       
    37 	void rewind(<[fp]>)
       
    38 	FILE *<[fp]>;
       
    39 
       
    40 DESCRIPTION
       
    41 <<rewind>> returns the file position indicator (if any) for the file
       
    42 or stream identified by <[fp]> to the beginning of the file.  It also
       
    43 clears any error indicator and flushes any pending output.
       
    44 
       
    45 RETURNS
       
    46 <<rewind>> does not return a result.
       
    47 
       
    48 PORTABILITY
       
    49 ANSI C requires <<rewind>>.
       
    50 
       
    51 No supporting OS subroutines are required.
       
    52 */
       
    53 
       
    54 #include <stdio.h>
       
    55 /**
       
    56 Repositions the file pointer to the beginning of a stream.
       
    57 Sets the file pointer associated with the stream 
       
    58 to the beginning of the file.
       
    59 @param Pointer to an open file.
       
    60 */
       
    61 EXPORT_C void
       
    62 rewind (FILE * fp)
       
    63 {
       
    64   (void) fflush (fp);
       
    65   clearerr (fp);
       
    66   if (fp->_seek == NULL)
       
    67     return;			/* ??? */
       
    68   fp->_r = 0;
       
    69   fp->_p = fp->_bf._base;
       
    70   (void) (*fp->_seek) (fp->_cookie, (fpos_t) 0, SEEK_SET);
       
    71 }