Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6536 serge 1
/*
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
<>---restore position of a stream or file
21
 
22
INDEX
23
	fsetpos
24
INDEX
25
	_fsetpos_r
26
 
27
ANSI_SYNOPSIS
28
	#include 
29
	int fsetpos(FILE *<[fp]>, const fpos_t *<[pos]>);
30
	int _fsetpos_r(struct _reent *<[ptr]>, FILE *<[fp]>,
31
	               const fpos_t *<[pos]>);
32
 
33
TRAD_SYNOPSIS
34
	#include 
35
	int fsetpos(<[fp]>, <[pos]>)
36
	FILE *<[fp]>;
37
	fpos_t *<[pos]>;
38
 
39
	int _fsetpos_r(<[ptr]>, <[fp]>, <[pos]>)
40
	struct _reent *<[ptr]>;
41
	FILE *<[fp]>;
42
	fpos_t *<[pos]>;
43
 
44
DESCRIPTION
45
Objects of type <> can have a ``position'' that records how much
46
of the file your program has already read.  Many of the <> functions
47
depend on this position, and many change it as a side effect.
48
 
49
You can use <> to return the file identified by <[fp]> to a previous
50
position <<*<[pos]>>> (after first recording it with <>).
51
 
52
See <> for a similar facility.
53
 
54
RETURNS
55
<> returns <<0>> when successful.  If <> fails, the
56
result is <<1>>.  The reason for failure is indicated in <>:
57
either <> (the stream identified by <[fp]> doesn't support
58
repositioning) or <> (invalid file position).
59
 
60
PORTABILITY
61
ANSI C requires <>, but does not specify the nature of
62
<<*<[pos]>>> beyond identifying it as written by <>.
63
 
64
Supporting OS subroutines required: <>, <>, <>,
65
<>, <>, <>, <>.
66
*/
67
 
68
#include <_ansi.h>
69
#include 
70
#include 
71
 
72
int
73
_DEFUN(_fsetpos_r, (ptr, iop, pos),
74
       struct _reent * ptr _AND
75
       FILE * iop          _AND
76
       _CONST _fpos_t * pos)
77
{
78
  int x = _fseek_r (ptr, iop, *pos, SEEK_SET);
79
 
80
  if (x != 0)
81
    return 1;
82
  return 0;
83
}
84
 
85
#ifndef _REENT_ONLY
86
 
87
int
88
_DEFUN(fsetpos, (iop, pos),
89
       FILE * iop _AND
90
       _CONST _fpos_t * pos)
91
{
92
  return _fsetpos_r (_REENT, iop, pos);
93
}
94
 
95
#endif /* !_REENT_ONLY */