OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [stdio/] [fgetpos.c] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
/*
2
FUNCTION
3
<<fgetpos>>---record position in a stream or file
4
 
5
INDEX
6
        fgetpos
7
 
8
ANSI_SYNOPSIS
9
        #include <stdio.h>
10
        int fgetpos(FILE *<[fp]>, fpos_t *<[pos]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <stdio.h>
14
        int fgetpos(<[fp]>, <[pos]>)
15
        FILE *<[fp]>;
16
        fpos_t *<[pos]>;
17
 
18
DESCRIPTION
19
Objects of type <<FILE>> can have a ``position'' that records how much
20
of the file your program has already read.  Many of the <<stdio>> functions
21
depend on this position, and many change it as a side effect.
22
 
23
You can use <<fgetpos>> to report on the current position for a file
24
identified by <[fp]>; <<fgetpos>> will write a value
25
representing that position at <<*<[pos]>>>.  Later, you can
26
use this value with <<fsetpos>> to return the file to this
27
position.
28
 
29
In the current implementation, <<fgetpos>> simply uses a character
30
count to represent the file position; this is the same number that
31
would be returned by <<ftell>>.
32
 
33
RETURNS
34
<<fgetpos>> returns <<0>> when successful.  If <<fgetpos>> fails, the
35
result is <<1>>.  Failure occurs on streams that do not support
36
positioning; the global <<errno>> indicates this condition with the
37
value <<ESPIPE>>.
38
 
39
PORTABILITY
40
<<fgetpos>> is required by the ANSI C standard, but the meaning of the
41
value it records is not specified beyond requiring that it be
42
acceptable as an argument to <<fsetpos>>.  In particular, other
43
conforming C implementations may return a different result from
44
<<ftell>> than what <<fgetpos>> writes at <<*<[pos]>>>.
45
 
46
No supporting OS subroutines are required.
47
*/
48
 
49
#include <stdio.h>
50
 
51
int
52
_DEFUN (fgetpos, (fp, pos),
53
        FILE * fp _AND
54
        fpos_t * pos)
55
{
56
  *pos = ftell (fp);
57
 
58
  if (*pos != -1)
59
    return 0;
60
  return 1;
61
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.