-
Notifications
You must be signed in to change notification settings - Fork 0
/
c_fseek.c
59 lines (44 loc) · 1.84 KB
/
c_fseek.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
///////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
/*
fseek, fseeko - reposition a file-position indicator in a stream
fseek sets the file position of the STREAM to the given OFFSET.
ISTAT = 0 if OK ,
= -1 on error.
*/
void c_fseek_ ( FILE **stream, long *offset, int *whence, int *istat )
{
*istat = fseek ( *stream, *offset, *whence );
}
////////////////////////////////////////////////////////////////////////////////
//
// New version:
// Pass arguments using its reference with value in integer(8), i.e.
// intptr_t defined in /usr/include/stdint.h
//
#include <stdint.h>
void c_fseek_intref_ (
intptr_t *iptr, long *offset, int *whence, int *istat )
{
*istat = fseek ( (FILE *) (*iptr), *offset, *whence );
}
////////////////////////////////////////////////////////////////////////////////
/*
The possibilities for the argument WHENCE in fseek():
SEEK_SET = 0 Seek from beginning of file.
SEEK_CUR = 1 Seek from current position.
SEEK_END = 2 Seek from end of file.
There are three ways to position a standard I/O stream:
1. The two functions ftell() and fseek(). They have been around since
Version 7, but they assume that a file’s position can be stored in a long
integer (i.e. 8 bytes).
2. The two functions ftello() and fseeko(). They were introduced in the
Single UNIX Specification to allow for file offsets that might not fit in
a long integer. They replace the long integer with the off_t data type,
i.e. 8 bytes.
3. The two functions fgetpos() and fsetpos(). They were introduced by
ISO C. They use an abstract data type, fpos_t (18 bytes), that records
a file's position. This datatype can be made as big as necessary to
record a file's position.
*/
//