freebsd-dev/contrib/libf2c/libI77/ftell_.c

36 lines
677 B
C
Raw Normal View History

2001-12-18 04:13:58 +00:00
#include "config.h"
1999-09-18 10:51:31 +00:00
#include "f2c.h"
#include "fio.h"
2003-07-11 03:42:19 +00:00
static FILE *
unit_chk (integer Unit, char *who)
1999-09-18 10:51:31 +00:00
{
2003-07-11 03:42:19 +00:00
if (Unit >= MXUNIT || Unit < 0)
f__fatal (101, who);
return f__units[Unit].ufd;
}
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
integer
G77_ftell_0 (integer * Unit)
1999-09-18 10:51:31 +00:00
{
2003-07-11 03:42:19 +00:00
FILE *f;
return (f = unit_chk (*Unit, "ftell")) ? (integer) FTELL (f) : -1L;
}
1999-09-18 10:51:31 +00:00
2003-07-11 03:42:19 +00:00
integer
G77_fseek_0 (integer * Unit, integer * offset, integer * xwhence)
1999-09-18 10:51:31 +00:00
{
2003-07-11 03:42:19 +00:00
FILE *f;
int w = (int) *xwhence;
1999-09-18 10:51:31 +00:00
#ifdef SEEK_SET
2003-07-11 03:42:19 +00:00
static int wohin[3] = { SEEK_SET, SEEK_CUR, SEEK_END };
1999-09-18 10:51:31 +00:00
#endif
2003-07-11 03:42:19 +00:00
if (w < 0 || w > 2)
w = 0;
1999-09-18 10:51:31 +00:00
#ifdef SEEK_SET
2003-07-11 03:42:19 +00:00
w = wohin[w];
1999-09-18 10:51:31 +00:00
#endif
2003-07-11 03:42:19 +00:00
return !(f = unit_chk (*Unit, "fseek"))
|| FSEEK (f, (off_t) * offset, w) ? 1 : 0;
}