sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* FUNCTION
|
sl@0
|
16 |
* <<fsetpos>>---restore position of a stream or file
|
sl@0
|
17 |
* INDEX
|
sl@0
|
18 |
* fsetpos
|
sl@0
|
19 |
* ANSI_SYNOPSIS
|
sl@0
|
20 |
* #include <stdio.h>
|
sl@0
|
21 |
* int fsetpos(FILE *<[fp]>, const fpos_t *<[pos]>);
|
sl@0
|
22 |
* TRAD_SYNOPSIS
|
sl@0
|
23 |
* #include <stdio.h>
|
sl@0
|
24 |
* int fsetpos(<[fp]>, <[pos]>)
|
sl@0
|
25 |
* FILE *<[fp]>;
|
sl@0
|
26 |
* fpos_t *<[pos]>;
|
sl@0
|
27 |
* Objects of type <<FILE>> can have a ``position'' that records how much
|
sl@0
|
28 |
* of the file your program has already read. Many of the <<stdio>> functions
|
sl@0
|
29 |
* depend on this position, and many change it as a side effect.
|
sl@0
|
30 |
* You can use <<fsetpos>> to return the file identified by <[fp]> to a previous
|
sl@0
|
31 |
* position <<*<[pos]>>> (after first recording it with <<fgetpos>>).
|
sl@0
|
32 |
* See <<fseek>> for a similar facility.
|
sl@0
|
33 |
* RETURNS
|
sl@0
|
34 |
* <<fgetpos>> returns <<0>> when successful. If <<fgetpos>> fails, the
|
sl@0
|
35 |
* result is <<1>>. The reason for failure is indicated in <<errno>>:
|
sl@0
|
36 |
* either <<ESPIPE>> (the stream identified by <[fp]> doesn't support
|
sl@0
|
37 |
* repositioning) or <<EINVAL>> (invalid file position).
|
sl@0
|
38 |
* PORTABILITY
|
sl@0
|
39 |
* ANSI C requires <<fsetpos>>, but does not specify the nature of
|
sl@0
|
40 |
* <<*<[pos]>>> beyond identifying it as written by <<fgetpos>>.
|
sl@0
|
41 |
* Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
|
sl@0
|
42 |
* <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
|
sl@0
|
43 |
*
|
sl@0
|
44 |
*
|
sl@0
|
45 |
*/
|
sl@0
|
46 |
|
sl@0
|
47 |
|
sl@0
|
48 |
|
sl@0
|
49 |
#include <stdio.h>
|
sl@0
|
50 |
|
sl@0
|
51 |
/**
|
sl@0
|
52 |
Reposition file pointer to a saved location.
|
sl@0
|
53 |
@return If successful the function returns 0.
|
sl@0
|
54 |
Otherwise it returns nonzero and sets the global variable errno to a non-zero value.
|
sl@0
|
55 |
@param iop Pointer to an open file.
|
sl@0
|
56 |
@param pos Position value obtained from a previous call to fgetpos that indicates
|
sl@0
|
57 |
the position of the file pointer at that moment.
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
EXPORT_C int
|
sl@0
|
60 |
fsetpos (FILE * iop, const fpos_t * pos)
|
sl@0
|
61 |
{
|
sl@0
|
62 |
int x = fseek (iop, *pos, SEEK_SET);
|
sl@0
|
63 |
|
sl@0
|
64 |
if (x != 0)
|
sl@0
|
65 |
return 1;
|
sl@0
|
66 |
return 0;
|
sl@0
|
67 |
}
|