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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [stdio/] [fsetpos.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
<<fsetpos>>---restore position of a stream or file
4
 
5
INDEX
6
        fsetpos
7
 
8
ANSI_SYNOPSIS
9
        #include <stdio.h>
10
        int fsetpos(FILE *<[fp]>, const fpos_t *<[pos]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <stdio.h>
14
        int fsetpos(<[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 <<fsetpos>> to return the file identified by <[fp]> to a previous
24
position <<*<[pos]>>> (after first recording it with <<fgetpos>>).
25
 
26
See <<fseek>> for a similar facility.
27
 
28
RETURNS
29
<<fgetpos>> returns <<0>> when successful.  If <<fgetpos>> fails, the
30
result is <<1>>.  The reason for failure is indicated in <<errno>>:
31
either <<ESPIPE>> (the stream identified by <[fp]> doesn't support
32
repositioning) or <<EINVAL>> (invalid file position).
33
 
34
PORTABILITY
35
ANSI C requires <<fsetpos>>, but does not specify the nature of
36
<<*<[pos]>>> beyond identifying it as written by <<fgetpos>>.
37
 
38
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
39
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
40
*/
41
 
42
#include <stdio.h>
43
 
44
int
45
_DEFUN (fsetpos, (iop, pos),
46
        FILE * iop _AND
47
        _CONST fpos_t * pos)
48
{
49
  int x = fseek (iop, *pos, SEEK_SET);
50
 
51
  if (x != 0)
52
    return 1;
53
  return 0;
54
}

powered by: WebSVN 2.1.0

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