OSDN Git Service

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