os/ossrv/genericopenlibs/cstdlib/LSTDIO/FGETPOS.C
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LSTDIO/FGETPOS.C	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,71 @@
     1.4 +/*
     1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +* FUNCTION
    1.19 +* <<fgetpos>>---record position in a stream or file
    1.20 +* INDEX
    1.21 +* fgetpos
    1.22 +* ANSI_SYNOPSIS
    1.23 +* #include <stdio.h>
    1.24 +* int fgetpos(FILE *<[fp]>, fpos_t *<[pos]>);
    1.25 +* TRAD_SYNOPSIS
    1.26 +* #include <stdio.h>
    1.27 +* int fgetpos(<[fp]>, <[pos]>)
    1.28 +* FILE *<[fp]>;
    1.29 +* fpos_t *<[pos]>;
    1.30 +* Objects of type <<FILE>> can have a ``position'' that records how much
    1.31 +* of the file your program has already read.  Many of the <<stdio>> functions
    1.32 +* depend on this position, and many change it as a side effect.
    1.33 +* You can use <<fgetpos>> to report on the current position for a file
    1.34 +* identified by <[fp]>; <<fgetpos>> will write a value
    1.35 +* representing that position at <<*<[pos]>>>.  Later, you can
    1.36 +* use this value with <<fsetpos>> to return the file to this
    1.37 +* position.
    1.38 +* In the current implementation, <<fgetpos>> simply uses a character
    1.39 +* count to represent the file position; this is the same number that
    1.40 +* would be returned by <<ftell>>.
    1.41 +* RETURNS
    1.42 +* <<fgetpos>> returns <<0>> when successful.  If <<fgetpos>> fails, the
    1.43 +* result is <<1>>.  Failure occurs on streams that do not support
    1.44 +* positioning; the global <<errno>> indicates this condition with the
    1.45 +* value <<ESPIPE>>.
    1.46 +* PORTABILITY
    1.47 +* <<fgetpos>> is required by the ANSI C standard, but the meaning of the
    1.48 +* value it records is not specified beyond requiring that it be
    1.49 +* acceptable as an argument to <<fsetpos>>.  In particular, other
    1.50 +* conforming C implementations may return a different result from
    1.51 +* <<ftell>> than what <<fgetpos>> writes at <<*<[pos]>>>.
    1.52 +* No supporting OS subroutines are required.
    1.53 +* 
    1.54 +*
    1.55 +*/
    1.56 +
    1.57 +
    1.58 +
    1.59 +#include <stdio.h>
    1.60 +/**
    1.61 +Get position in a stream.
    1.62 +@return 0 value indicates success. non-zero value indicates error.
    1.63 +@param fp pointer to an open file. 
    1.64 +@param pos pointer to a fpos_t object where the position will be stored. 
    1.65 +*/
    1.66 +EXPORT_C int
    1.67 +fgetpos (FILE * fp, fpos_t * pos)
    1.68 +{
    1.69 +  *pos = ftell (fp);
    1.70 +
    1.71 +  if (*pos != -1)
    1.72 +    return 0;
    1.73 +  return 1;
    1.74 +}