Initial revision
[official-gcc.git] / gcc / f / runtime / libI77 / ftell_.c
blob1bd03be325a92397413b3f50252cdb59e78eb904
1 #include "f2c.h"
2 #include "fio.h"
4 static FILE *
5 #ifdef KR_headers
6 unit_chk(Unit, who) integer Unit; char *who;
7 #else
8 unit_chk(integer Unit, char *who)
9 #endif
11 if (Unit >= MXUNIT || Unit < 0)
12 f__fatal(101, who);
13 return f__units[Unit].ufd;
16 integer
17 #ifdef KR_headers
18 G77_ftell_0 (Unit) integer *Unit;
19 #else
20 G77_ftell_0 (integer *Unit)
21 #endif
23 FILE *f;
24 return (f = unit_chk(*Unit, "ftell")) ? ftell(f) : -1L;
27 integer
28 #ifdef KR_headers
29 G77_fseek_0 (Unit, offset, xwhence) integer *Unit, *offset, *xwhence;
30 #else
31 G77_fseek_0 (integer *Unit, integer *offset, integer *xwhence)
32 #endif
34 FILE *f;
35 int w = (int)*xwhence;
36 #ifdef SEEK_SET
37 static int wohin[3] = { SEEK_SET, SEEK_CUR, SEEK_END };
38 #endif
39 if (w < 0 || w > 2)
40 w = 0;
41 #ifdef SEEK_SET
42 w = wohin[w];
43 #endif
44 return !(f = unit_chk(*Unit, "fseek"))
45 || fseek(f, *offset, w) ? 1 : 0;