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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [stdio/] [fgetpos.c] - Blame information for rev 455

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

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 * Copyright (c) 1990 The Regents of the University of California.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms are permitted
6
 * provided that the above copyright notice and this paragraph are
7
 * duplicated in all such forms and that any documentation,
8
 * advertising materials, and other materials related to such
9
 * distribution and use acknowledge that the software was developed
10
 * by the University of California, Berkeley.  The name of the
11
 * University may not be used to endorse or promote products derived
12
 * from this software without specific prior written permission.
13
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16
 */
17
 
18
/*
19
FUNCTION
20
<<fgetpos>>---record position in a stream or file
21
 
22
INDEX
23
        fgetpos
24
INDEX
25
        _fgetpos_r
26
 
27
ANSI_SYNOPSIS
28
        #include <stdio.h>
29
        int fgetpos(FILE *<[fp]>, fpos_t *<[pos]>);
30
        int _fgetpos_r(struct _reent *<[ptr]>, FILE *<[fp]>, fpos_t *<[pos]>);
31
 
32
TRAD_SYNOPSIS
33
        #include <stdio.h>
34
        int fgetpos(<[fp]>, <[pos]>)
35
        FILE *<[fp]>;
36
        fpos_t *<[pos]>;
37
 
38
        int _fgetpos_r(<[ptr]>, <[fp]>, <[pos]>)
39
        struct _reent *<[ptr]>;
40
        FILE *<[fp]>;
41
        fpos_t *<[pos]>;
42
 
43
DESCRIPTION
44
Objects of type <<FILE>> can have a ``position'' that records how much
45
of the file your program has already read.  Many of the <<stdio>> functions
46
depend on this position, and many change it as a side effect.
47
 
48
You can use <<fgetpos>> to report on the current position for a file
49
identified by <[fp]>; <<fgetpos>> will write a value
50
representing that position at <<*<[pos]>>>.  Later, you can
51
use this value with <<fsetpos>> to return the file to this
52
position.
53
 
54
In the current implementation, <<fgetpos>> simply uses a character
55
count to represent the file position; this is the same number that
56
would be returned by <<ftell>>.
57
 
58
RETURNS
59
<<fgetpos>> returns <<0>> when successful.  If <<fgetpos>> fails, the
60
result is <<1>>.  Failure occurs on streams that do not support
61
positioning; the global <<errno>> indicates this condition with the
62
value <<ESPIPE>>.
63
 
64
PORTABILITY
65
<<fgetpos>> is required by the ANSI C standard, but the meaning of the
66
value it records is not specified beyond requiring that it be
67
acceptable as an argument to <<fsetpos>>.  In particular, other
68
conforming C implementations may return a different result from
69
<<ftell>> than what <<fgetpos>> writes at <<*<[pos]>>>.
70
 
71
No supporting OS subroutines are required.
72
*/
73
 
74
#include <_ansi.h>
75
#include <reent.h>
76
#include <stdio.h>
77
 
78
int
79
_DEFUN(_fgetpos_r, (ptr, fp, pos),
80
       struct _reent * ptr _AND
81
       FILE * fp           _AND
82
       _fpos_t * pos)
83
{
84
  *pos = _ftell_r (ptr, fp);
85
 
86
  if (*pos != -1)
87
    {
88
      return 0;
89
    }
90
  return 1;
91
}
92
 
93
#ifndef _REENT_ONLY
94
 
95
int
96
_DEFUN(fgetpos, (fp, pos),
97
       FILE * fp _AND
98
       _fpos_t * pos)
99
{
100
  return _fgetpos_r (_REENT, fp, pos);
101
}
102
 
103
#endif /* !_REENT_ONLY */

powered by: WebSVN 2.1.0

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