sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * FUNCTION sl@0: * <>---restore position of a stream or file sl@0: * INDEX sl@0: * fsetpos sl@0: * ANSI_SYNOPSIS sl@0: * #include sl@0: * int fsetpos(FILE *<[fp]>, const fpos_t *<[pos]>); sl@0: * TRAD_SYNOPSIS sl@0: * #include sl@0: * int fsetpos(<[fp]>, <[pos]>) sl@0: * FILE *<[fp]>; sl@0: * fpos_t *<[pos]>; sl@0: * Objects of type <> can have a ``position'' that records how much sl@0: * of the file your program has already read. Many of the <> functions sl@0: * depend on this position, and many change it as a side effect. sl@0: * You can use <> to return the file identified by <[fp]> to a previous sl@0: * position <<*<[pos]>>> (after first recording it with <>). sl@0: * See <> for a similar facility. sl@0: * RETURNS sl@0: * <> returns <<0>> when successful. If <> fails, the sl@0: * result is <<1>>. The reason for failure is indicated in <>: sl@0: * either <> (the stream identified by <[fp]> doesn't support sl@0: * repositioning) or <> (invalid file position). sl@0: * PORTABILITY sl@0: * ANSI C requires <>, but does not specify the nature of sl@0: * <<*<[pos]>>> beyond identifying it as written by <>. sl@0: * Supporting OS subroutines required: <>, <>, <>, sl@0: * <>, <>, <>, <>. sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: sl@0: /** sl@0: Reposition file pointer to a saved location. sl@0: @return If successful the function returns 0. sl@0: Otherwise it returns nonzero and sets the global variable errno to a non-zero value. sl@0: @param iop Pointer to an open file. sl@0: @param pos Position value obtained from a previous call to fgetpos that indicates sl@0: the position of the file pointer at that moment. sl@0: */ sl@0: EXPORT_C int sl@0: fsetpos (FILE * iop, const fpos_t * pos) sl@0: { sl@0: int x = fseek (iop, *pos, SEEK_SET); sl@0: sl@0: if (x != 0) sl@0: return 1; sl@0: return 0; sl@0: }