~ubuntu-branches/ubuntu/trusty/libf2c2/trusty

« back to all changes in this revision

Viewing changes to ftell_.c

  • Committer: Bazaar Package Importer
  • Author(s): Alan Bain
  • Date: 2008-05-19 22:50:54 UTC
  • mfrom: (2.1.4 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080519225054-jlymia0wdvvfq7dg
Tags: 20061008-4
Remove CVS directory left in source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "f2c.h"
 
2
#include "fio.h"
 
3
#ifdef __cplusplus
 
4
extern "C" {
 
5
#endif
 
6
 
 
7
 static FILE *
 
8
#ifdef KR_headers
 
9
unit_chk(Unit, who) integer Unit; char *who;
 
10
#else
 
11
unit_chk(integer Unit, const char *who)
 
12
#endif
 
13
{
 
14
        if (Unit >= MXUNIT || Unit < 0)
 
15
                f__fatal(101, who);
 
16
        return f__units[Unit].ufd;
 
17
        }
 
18
 
 
19
 integer
 
20
#ifdef KR_headers
 
21
ftell_(Unit) integer *Unit;
 
22
#else
 
23
ftell_(integer *Unit)
 
24
#endif
 
25
{
 
26
        FILE *f;
 
27
        return (f = unit_chk(*Unit, "ftell")) ? ftell(f) : -1L;
 
28
        }
 
29
 
 
30
 int
 
31
#ifdef KR_headers
 
32
fseek_(Unit, offset, whence) integer *Unit, *offset, *whence;
 
33
#else
 
34
fseek_(integer *Unit, integer *offset, integer *whence)
 
35
#endif
 
36
{
 
37
        FILE *f;
 
38
        int w = (int)*whence;
 
39
#ifdef SEEK_SET
 
40
        static int wohin[3] = { SEEK_SET, SEEK_CUR, SEEK_END };
 
41
#endif
 
42
        if (w < 0 || w > 2)
 
43
                w = 0;
 
44
#ifdef SEEK_SET
 
45
        w = wohin[w];
 
46
#endif
 
47
        return  !(f = unit_chk(*Unit, "fseek"))
 
48
                || fseek(f, *offset, w) ? 1 : 0;
 
49
        }
 
50
#ifdef __cplusplus
 
51
}
 
52
#endif